<div dir="ltr"><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px">I am writing a script to build some line charts in VTK, but I am having difficulty repositioning a vtkChartLegend object.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px">The python script below will create a plot. I would like to reposition the legend to the upper left-hand side of the chart so as to not interfere with the line plot. However, I am not able to make the legend move. I would appreciate any help to get the legend to re-position?</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px">I am running OSX (Yosemite) with Python 2.7.6 and VTK 6.3.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px"><br></p><span style="font-size:12.8px">#!/usr/bin/env python</span><br style="font-size:12.8px"><span style="font-size:12.8px">import vtk</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px"># Num. points</span><br style="font-size:12.8px"><span style="font-size:12.8px">n = 10</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px"># Create some data</span><br style="font-size:12.8px"><span style="font-size:12.8px">x = vtk.vtkFloatArray()</span><br style="font-size:12.8px"><span style="font-size:12.8px">y = vtk.vtkFloatArray()</span><br style="font-size:12.8px"><span style="font-size:12.8px">x.SetNumberOfTuples(n)</span><br style="font-size:12.8px"><span style="font-size:12.8px">x.SetName('x')</span><br style="font-size:12.8px"><span style="font-size:12.8px">y.SetNumberOfTuples(n)</span><br style="font-size:12.8px"><span style="font-size:12.8px">y.SetName('y')</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">for i in range(10):</span><br style="font-size:12.8px"><span style="font-size:12.8px">    x.SetValue(i, float(i))</span><br style="font-size:12.8px"><span style="font-size:12.8px">    y.SetValue(i, float(2*i))</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px"># Create the table and line</span><br style="font-size:12.8px"><span style="font-size:12.8px">table = vtk.vtkTable()</span><br style="font-size:12.8px"><span style="font-size:12.8px">table.AddColumn(x)</span><br style="font-size:12.8px"><span style="font-size:12.8px">table.AddColumn(y)</span><br style="font-size:12.8px"><span style="font-size:12.8px">line = vtk.vtkPlotLine()</span><br style="font-size:12.8px"><span style="font-size:12.8px">line.SetInputData(table, 0, 1)</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px"># Create chart</span><br style="font-size:12.8px"><span style="font-size:12.8px">chart = vtk.vtkChartXY()</span><br style="font-size:12.8px"><span style="font-size:12.8px">chart.AddPlot(line)</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px"># Create view</span><br style="font-size:12.8px"><span style="font-size:12.8px">view = vtk.vtkContextActor()</span><br style="font-size:12.8px"><span style="font-size:12.8px">view.GetScene().AddItem(chart)</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px"># Renderer</span><br style="font-size:12.8px"><span style="font-size:12.8px">renderer = vtk.vtkRenderer()</span><br style="font-size:12.8px"><span style="font-size:12.8px">renderer.SetBackground(1,1,1)</span><br style="font-size:12.8px"><span style="font-size:12.8px">renderer.AddViewProp(view)</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px"># Legend</span><br style="font-size:12.8px"><span style="font-size:12.8px">chart.SetShowLegend(True)</span><br style="font-size:12.8px"><span style="font-size:12.8px">legend = chart.GetLegend()</span><br style="font-size:12.8px"><span style="font-size:12.8px">legend.SetPoint(0, 20) # This doesn't seem to do anything</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px"># Window</span><br style="font-size:12.8px"><span style="font-size:12.8px">window = vtk.vtkRenderWindow()</span><br style="font-size:12.8px"><span style="font-size:12.8px">window.AddRenderer(renderer)</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px"># Interactor</span><br style="font-size:12.8px"><span style="font-size:12.8px">interactor = vtk.vtkRenderWindowInteractor(</span><span style="font-size:12.8px">)</span><br style="font-size:12.8px"><span style="font-size:12.8px">interactor.SetRenderWindow(</span><span style="font-size:12.8px">window)</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px"># Render</span><br style="font-size:12.8px"><span style="font-size:12.8px">window.Render()</span><br style="font-size:12.8px"><span style="font-size:12.8px">renderer.Render()</span><br style="font-size:12.8px"><span style="font-size:12.8px">interactor.Start()</span><br></div>