<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 8, 2015 at 1:27 PM, Cory Quammen <span dir="ltr"><<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Well shoot, that member function must not be wrapped.<div><br></div><div>Instead, try this</div><div><br></div><div><span style="font-size:12.8px">legend = chart.GetLegend()</span></div><div>legend.SetHorizontalAlignment(vtk.vtkChartLegend.CUSTOM)</div><div>legend.SetVerticalAlignment(vtk.vtkChartLegend.CUSTOM)<br><span style="font-size:12.8px">legend.SetPoint(0, 20)</span></div></div></blockquote><div><br></div><div>This causes the legend to move to the lower left in the window, SetPoint does nothing.</div><div><br></div><div>Using the Set(Horizontal/Vertical)Alignment methods move the legend to the various points within the </div><div>plot window. For example, the following places it where I was hoping to move the legend.</div><div><div>legend.SetHorizontalAlignment(vtk.vtkChartLegend.LEFT)</div><div>legend.SetVerticalAlignment(vtk.vtkChartLegend.TOP)</div></div><div><br></div><div>However, this SetPoint method does not seem to change anything. Perhaps I am just not understanding how the bounding box works for the object. I was thinking that SetPoint would locate the corner of the legend box at the specified point and that the Set(Horizontal/Vertical)Alignment methods indicate how this box aligns to the point.</div><div><br></div><div>The behavior seems to be that the legend has a bounding box equal to the chart axis dimensions and that the alignment methods alter the placement of the legend box within this larger bounding box.</div><div><br></div><div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div> </div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.8px"></span></div><div><span style="font-size:12.8px">HTH,</span></div><div><span style="font-size:12.8px">Cory</span></div><div><span style="font-size:12.8px"><br></span></div></div><div class=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 8, 2015 at 3:00 PM, Slaughter, Andrew E <span dir="ltr"><<a href="mailto:andrew.slaughter@inl.gov" target="_blank">andrew.slaughter@inl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Yes, that function does not exist.</div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 8, 2015 at 12:45 PM, Cory Quammen <span dir="ltr"><<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Hi Andrew,</div><div><br></div>Have you tried vtkChartXY::SetLegendPosition(const vtkRectf & rect), e.g.<div><br></div><div>rect = vtkRectf(0, 20, ?, ?)</div><div>char.SetLegendPosition(rect)</div><div><br></div><div>HTH,</div><div>Cory</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Thu, Oct 8, 2015 at 2:33 PM, Slaughter, Andrew E <span dir="ltr"><<a href="mailto:andrew.slaughter@inl.gov" target="_blank">andrew.slaughter@inl.gov</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><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>
<br></div></div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</div>
</div></div></blockquote></div><br></div></div>