Jump to content

Set the Default "ShapeBy" Shape on a ScatterPlot


Previn Chetty 3

Recommended Posts

Hi Guys, I was wondering if there is a method to change the default shape used on the ShapeBy on a scatterPlot. I have a dropdown that changes the Marker value (column that's used). When I change it, the shape defaults. I need the shape to stay fixed on TriangleUP. Is there a method to do this through Spotfire Or will I need to get this done through an IronPython script If so, how would I do this

I have tried adding this but it does not seem to work. This should kick off each time I change the MarkerBy.

#set shapeby

MyChart.ShapeAxis.DefaultShape = MarkerShape(MarkerType.TriangleUp)

 

Spotfire V7.12

Link to comment
Share on other sites

This hasn't fully solved my problem.

Looks like the only option I have is a script.

Does anyone know how to change the ShapeBy through a script

This is my current Script (for information purposes):

***I'm new to Python***

from Spotfire.Dxp.Application.Visuals import *

from Spotfire.Dxp.Data import DataPropertyClass

#get a reference to your viz script parameter

myChart = MyChart = vis.As[scatterPlot]()

#read min,max from document properties

Xmin = Document.Data.Properties.GetProperty(DataPropertyClass.Document, "LIFX").Value

Xmax = Document.Data.Properties.GetProperty(DataPropertyClass.Document, "UIFX").Value

Ymin = Document.Data.Properties.GetProperty(DataPropertyClass.Document, "LIFY").Value

Ymax = Document.Data.Properties.GetProperty(DataPropertyClass.Document, "UIFY").Value

Outlier = Document.Data.Properties.GetProperty(DataPropertyClass.Document, "Outliers").Value

#apply zoom range

if Outlier == 'Hide':

MyChart.XAxis.ManualZoom = False

MyChart.YAxis.ManualZoom = False

MyChart.YAxis.Range = AxisRange(Ymin,Ymax);

MyChart.XAxis.Range = AxisRange(Xmin,Xmax);

else:

MyChart.YAxis.Range = AxisRange('Automatic','Automatic');

MyChart.XAxis.Range = AxisRange('Automatic','Automatic');

MyChart.XAxis.ManualZoom = True

MyChart.YAxis.ManualZoom = True

#set shapeby

MyChart.ShapeAxis.DefaultShape = MarkerShape(MarkerType.TriangleUp)

Link to comment
Share on other sites

  • 4 weeks later...

Here is the solution that worked for me. Hope it helps someone in future.

This IronPython script changed the ShapeBy for me each time I changed the "MarkerBy"(shape would reset to the default).

from Spotfire.Dxp.Application.Visuals import ScatterPlot,MarkerShape,MarkerType,CategoryKey

vis = v.As[scatterPlot]()

#params

shape = Document.Properties["ShapeByType"]

category = Document.Properties["ShapeByCategory"]

markerType = getattr(MarkerType,shape)

vis.ShapeAxis.ShapeMap[category] = MarkerShape(markerType)

#list available shapes to copy and add data table from clipboard to populate shape dropdown:

shapes = [a for a in dir(MarkerType) if not callable(getattr(MarkerType,a)) and not '__' in a ]

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...