Jump to content

How to set colors to specific columns in scatter plot in TIBCO Spotfire using IronPython scripting

Shinya Ito

Recommended Posts


Sorry to ask such a basic question, but could you tell me how to set favorite colors to specific columns in a scatter plot in TIBCO Spotfire using IronPython scripting

For example, when I make a scatter plot with X-axis of measurement date and Y-axis of 3 measured data of average, minimum, maximum, I want to assign green to average, blue to minimum, and red to maximum. But I don't know how to desribeit.

When I set colors to columns automatically, I know a following script. But I dont want to use this now.

from Spotfire.Dxp.Application.Visuals import *

vis = vis.As[scatterPlot]()

vis.ShapeAxis.Expression = ''

Thanks a lot.


Link to comment
Share on other sites

Hi Shandilyasan,Thank you for your help, but I could not apply the sample of Bar chart to my case simply. I found out that Id written an appropriate example in my question. Im so sorry. I want to make a following scatter plot. I dont use Trellis.  X-axis: Date

  Y-axis: Measured value for 3 samples (A,B, and C)


  Data is a table like below.

Sample Date Measured value
 I want to assign specific 3 colors to each sample (A is red, B is blue, and C is Yellow). How should I describe thatThanks a lot.Shinya
Link to comment
Share on other sites

Can you try the following,

from Spotfire.Dxp.Application.Visuals import CategoryKey

from System.Drawing import Color

from System.Collections.Generic import List

from Spotfire.Dxp.Framework.Library import *


#add a script parameter schart referring to your visualization



chart.ColorAxis.Expression = "Sample"


#Get Categories based on expression




#Add colors to each category

chart.ColorAxis.Coloring.SetColorForCategory(keys[0], Color.FromName("Red"))

chart.ColorAxis.Coloring.SetColorForCategory(keys[1], Color.FromName("Blue"))

chart.ColorAxis.Coloring.SetColorForCategory(keys[2], Color.FromName("Yellow"))

Link to comment
Share on other sites

  • 3 years later...

Here is an example on how to toggle from categorical to continuous.

from Spotfire.Dxp.Application.Visuals import Axis, LineChart, AxisModevis = vis.As[LineChart]()expr = vis.XAxis.Expression if vis.XAxis.AxisMode == AxisMode.Continuous: vis.XAxis.Expression = "<" + expr + ">"else: vis.XAxis.Expression = expr[1:-1]

Now if you want to cycle through the category modes:

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