Jump to content

How to set categories option in x-axis for scatter plot in Spotfire through iron python????


GURUPRASATH T V

Recommended Posts

There is a useful website with advice for similar things:

https://www.sf-ref.com/ironpython/visualizations/scatter-plot/y-axis/

However I did not find there a direct answer to your question, but I think it helps formulating one.

The difference between treating an axis as categorical or continuous is simply the presence on triangular brackets < > around the axis expression (you can verify it if you right-click on the axis drop-down and choose Custom Expression to get to the expression editor.

So the script below would toggle between categorical and continuous by simply detecting the brackets and adding them if they are not there, removing them if they are. You can tailor it to your needs.

It assumes that myVis is an input variable of type Visualization.

from Spotfire.Dxp.Application.Visuals import * myVis = myVis.As[Visualization]()expr= myVis.XAxis.Expression  if expr[0]=='<': myVis.XAxis.Expression = expr[1:-1]else: myVis.XAxis.Expression = '<'+expr+'>'
Link to comment
Share on other sites

Using a similar reasoning, the difference between the two XAxis expressions is NEST vs CROSS in the expression:

from Spotfire.Dxp.Application.Visuals import * myVis = myVis.As[Visualization]()expr= myVis.XAxis.Expression  if 'NEST' in expr: myVis.XAxis.Expression =expr.replace('NEST','CROSS')if 'CROSS' in expr: myVis.XAxis.Expression =expr.replace('CROSS','NEST')  
Link to comment
Share on other sites

Hi Gaia,

Thank you for response I would try this code. I'm can not able to add the column in x-axis in programmatically , I need to add multiple column in x axis and y axis through iron python program.....

And, I add screenshot for your reference in this picture, Now I add the column in manually. But, I need to automate through iron python.

can you please share your option on this???

  1. from Spotfire.Dxp.Application.Visuals import *
  2.  
  3. myVis = myVis.As[Visualization]()
  4. expr= myVis.XAxis.Expression
  5.  
  6. if expr[0]=='<':
  7. myVis.XAxis.Expression = expr[1:-1]
  8. else:
  9. myVis.XAxis.Expression = '<'+expr+'>'

Screenshot(1).thumb.png.dd34f0bcddf02281c435b9ed2509c7b4.png

Link to comment
Share on other sites

Is your question about how to build a scatterplot programmatically? Can you elaborate a bit on your process?

I.e. you have a starting scatterplot with some X and Y axis defined

you want a script to change the X and Y dynamically?

Otherwise, why would you need a script to add X and Y columns?

Link to comment
Share on other sites

Hi Gaia ,

Now, I am write this script to automate the scatter plot to add the multiple column in x and y axis but can not able to get the output. script is run there is no error show in error console window.

from Spotfire.Dxp.Application.Visuals import *

from Spotfire.Dxp.Application.Visuals import ScatterPlot

ScatterPlot = Document.ActivePageReference.Visuals.AddNew[scatterPlot]()

ScatterPlot.AutoConfigure()

ScatterPlot.Title = 'PSRR_Measure'

ScatterPlot.ShowDescription = True

ScatterPlot.Description = 'This Plot Repected by PSRR VS SUPPLY how the data will scatter'

ScatterPlot.XAxis.Expression = "[supply_v]"

ScatterPlot.XAxis.Range = AxisRange(50, 250)

ScatterPlot.XAxis.Range = AxisRange(None, None)

ScatterPlot.XAxis.IncludeZeroInAutoZoom = True

ScatterPlot.XAxis.ManualZoom = True

ScatterPlot.XAxis.Scale.ShowGridlines = True

ScatterPlot.XAxis.TransformType = AxisTransformType.Log10 #Checked

ScatterPlot.XAxis.TransformType = AxisTransformType.None #Un-checked

ScatterPlot.XAxis.Scale.LabelOrientation = LabelOrientation.Horizontal

ScatterPlot.XAxis.Scale.LabelOrientation = LabelOrientation.Vertical

ScatterPlot.XAxis.Scale.LabelLayout = ScaleLabelLayout.MaximumNumberOfTicks

ScatterPlot.XAxis.Scale.MaximumNumberOfTicks = 15

ScatterPlot.XAxis.Scale.LabelLayout = ScaleLabelLayout.Automatic

expr = ScatterPlot.YAxis.Expression 

if expr[0]=='<':

ScatterPlot.YAxis.Expression = expr[1:-1]

else:

ScatterPlot.YAxis.Expression = '<'+expr+'>'

ScatterPlot.YAxis.Expression = "[DUT_ID], [time]"

ScatterPlot.YAxis.IndividualScaling = True

ScatterPlot.YAxis.IndividualScalingMode = IndividualScalingMode.Color

ScatterPlot.YAxis.IndividualScalingMode = IndividualScalingMode.Trellis

ScatterPlot.YAxis.ManualZoom = True

ScatterPlot.YAxis.IndexedRange["[DUT_ID]"] = AxisRange(50, 250)

ScatterPlot.YAxis.IndexedRange["[time]"] = AxisRange(-100, 150)

ScatterPlot.YAxis.IndexedRange["[DUT_ID]"] = AxisRange(None, None)

ScatterPlot.YAxis.IndexedIncludeZeroInAutoZoom["[DUT_ID]"] = True

ScatterPlot.YAxis.IndexedIncludeZeroInAutoZoom["[time]"] = False

image.thumb.png.e23e94f27aee544d3be01f3206306ba0.png

Link to comment
Share on other sites

can you not try the error's "suggestion" to color by (Column Names) and see if that gives you a plot?

Then you can put something like this in the script: here Axis.Default.Names is the expression you get when you manually specify to color by (Column Names)

myVis.ColorAxis.Expression = "<[Axis.Default.Names]>"
Link to comment
Share on other sites

Hello Guruprasath. To reply your original question, here is an example on how to toggle from categorical to continuous. vis

from Spotfire.Dxp.Application.Visuals import Axis, ScatterPlot, AxisMode //vis is a scatter plot visualization script parametervis = vis.As[scatterPlot]() if vis.XAxis.AxisMode == AxisMode.Continuous: vis.XAxis.Expression = "<" + vis.XAxis.Expression + ">"else: vis.XAxis.Expression = vis.XAxis.Expression[1:-1]

And here is an example on how to cycle through categorical modes (show all values, show filtered values, show filtered range)

from Spotfire.Dxp.Application.Visuals import Axis, LineChart, AxisMode, CategoryMode vis = vis.As[LineChart]()axis = vis.XAxis if axis.AxisMode == AxisMode.Categorical: if axis.CategoryMode == CategoryMode.ShowAll: axis.CategoryMode = CategoryMode.ShowFiltered elif axis.CategoryMode == CategoryMode.ShowFiltered: axis.CategoryMode = CategoryMode.ShowFilteredRange else: axis.CategoryMode = CategoryMode.ShowAll print axis.CategoryMode

If you have a different question that is not related to the original question, I encourage you to create a new question for a faster and more accurate response. The accuracy of the answer depends on the amount of details of your question. Please keep the questions clear and concise.

Link to comment
Share on other sites

 

Hello Jose, Thank you for reply, Still I have some more question to ask. Now I Know how to enable categorical modes in python scripts. Actually my question is how to select the multiple column in X-Axis through python ???

Please refer the given below image now I Select the multiple column in x axis this one now I do manually but I need to automate through python.. Can you please suggest how to do

Screenshot(4).thumb.png.1bb154ff60e0be33dabcf0d116fd3df9.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...