Jump to content

Funny Cat

Members
  • Posts

    30
  • Joined

  • Last visited

Community Answers

  1. Funny Cat's post in Heatmap Color Gradient from Document Properties was marked as the answer   
    I couldn't figure out how to access the colorbreakpoints in the heatmap.
    I ended up with making a heatmap using the scatterplot with tiled markers.
     
    In case somebody is interested in the script:
    from Spotfire.Dxp.Application.Visuals import *from System.Drawing import Colorfrom Spotfire.Dxp.Application.Visuals.ConditionalColoring import Coloring, ContinuousColorRule, ConditionValue, IntervalMode vcMap = visMap.As[VisualContent]() LSL = Document.Properties["LSL"]USL = Document.Properties["USL"] #remove old color rulescolorRule = vcMap.ColorAxis.Coloring.Clear()#create new color rulecr = vcMap.ColorAxis.Coloring.AddContinuousColorRule()cr.IntervalMode = IntervalMode.Gradient #Create ConditionValues with expressions and literalscv0 = ConditionValue.CreateExpression(str(LSL-0.000001))cv1 = ConditionValue.CreateLiteral(LSL)cv2 = ConditionValue.CreateLiteral(LSL+(USL-LSL)*0.1)cv3 = ConditionValue.CreateLiteral(LSL+(USL-LSL)*0.2)cv4 = ConditionValue.CreateLiteral(LSL+(USL-LSL)*0.3)cv5 = ConditionValue.CreateLiteral(LSL+(USL-LSL)*0.4)cv6 = ConditionValue.CreateLiteral(LSL+(USL-LSL)*0.5)cv7 = ConditionValue.CreateLiteral(LSL+(USL-LSL)*0.6)cv8 = ConditionValue.CreateLiteral(LSL+(USL-LSL)*0.7)cv9 = ConditionValue.CreateLiteral(LSL+(USL-LSL)*0.8)cv10 = ConditionValue.CreateLiteral(LSL+(USL-LSL)*0.9)cv11 = ConditionValue.CreateLiteral(USL)cv12 = ConditionValue.CreateExpression(str(USL+0.000001)) #Add breakpointscr.Breakpoints.Add(cv0,Color.FromArgb(170, 170, 170))cr.Breakpoints.Add(cv1,Color.FromArgb(75, 0, 130))cr.Breakpoints.Add(cv2,Color.FromArgb(38, 0, 193))cr.Breakpoints.Add(cv3,Color.FromArgb(0, 0, 255))cr.Breakpoints.Add(cv4,Color.FromArgb(0, 64, 128))cr.Breakpoints.Add(cv5,Color.FromArgb(12, 105, 12))cr.Breakpoints.Add(cv6,Color.FromArgb(128, 192, 0))cr.Breakpoints.Add(cv7,Color.FromArgb(255, 255, 0))cr.Breakpoints.Add(cv8,Color.FromArgb(255, 210, 0))cr.Breakpoints.Add(cv9,Color.FromArgb(255, 165, 0))cr.Breakpoints.Add(cv10,Color.FromArgb(255, 83, 0))cr.Breakpoints.Add(cv11,Color.FromArgb(255, 0, 0))cr.Breakpoints.Add(cv12,Color.FromArgb(35, 35, 35)) #Set manual display name for the two expressionsfor coloring in vcMap.ColorAxis.Coloring: for breakpoint in coloring.Breakpoints: if breakpoint.Value.Value == str(USL+0.000001): breakpoint.ManualDisplayName = 'higher' if breakpoint.Value.Value == str(LSL-0.000001): breakpoint.ManualDisplayName = 'lower'
  2. Funny Cat's post in Is there an easy way in Spotfire 12.0.0 LTS to get a different axis scale in a scatter or line plot? There's just the default "linear" and the option "logarithmic". I would like to get "normal probability scale" as in the python library mpl-probscale. was marked as the answer   
    Thanks for the answer.
    My current workaround is to plot the z-score instead and add horizontal lines for the % values I want to show.
    However, the solution is not very nice, since the position of the annotation is changing depending on display resolution/chart size, so it's not obvious which line has which value (however I added the values in the tooltip, so at least you can hover over the lines to see the percentages)
     
    For those who are interested how to do this automatically:
    make a list of percentages you want to display e.g. in excel, and name the column percentage calculate the z-score (in Excel using the function NORM.S.INV, or use the NormInv function of Spotfire) and name the column zscore In the column properties, set the formatting of the column percentage to 0.### % Add the following script, create the parameter vis and set it to your probability plot. Then run it: from Spotfire.Dxp.Application.Visuals import *from System.Drawing import *from Spotfire.Dxp.Data import * #Add the parameter vis - and set the value to your probability plotvc = vis.As[VisualContent]() # remove old percentage lines (in case you have to adjust the lines more than once)for fm in vc.FittingModels: if '%' in fm.Line.DisplayName: vc.FittingModels.Remove(fm) #define data table and se the cursors to the table columnseTable=Document.Data.Tables["zscore-percentage"]cur_p = DataValueCursor.CreateFormatted(eTable.Columns["percentage"])cur_z = DataValueCursor.CreateFormatted(eTable.Columns["zscore"]) #run through table to get the values and draw the linesfor row in eTable.GetRows(cur_p, cur_z): p = cur_p.CurrentValue.replace(",",".") z = cur_z.CurrentValue.replace(",",".") #print p,z  #draw lines horizontalLine=vc.FittingModels.AddHorizontalLine(z) myLine=horizontalLine.Line myLine.LineStyle=LineStyle.Dot myLine.Width=1 myLine.IsBackground=True myLine.CustomDisplayName=p labels_tooltips=horizontalLine.Line.Details #print lt.Name,lt.DisplayName,lt.ShowInLabel,lt.ShowInTooltip for lt in labels_tooltips: if lt.Name=='Name': lt.ShowInLabel=False if lt.Name=='y': lt.ShowInTooltip=False if p in ['0.1 %', '1 %', '10 %', '50 %', '90 %', '99 %', '99.9 %']: myLine.Color=Color.Gray for lt in labels_tooltips: if lt.Name=='Name': lt.ShowInLabel=True else: myLine.Color=Color.LightGray
×
×
  • Create New...