[vtkusers] magnify vtkChartXY image

Randy Heiland heiland at indiana.edu
Fri Dec 14 16:16:08 EST 2012


Is there some way to magnify (or set the resolution of) a rendered chart, in order to generate a higher-res image from a Writer?  e.g. I attempted the following simple Python script, which did indeed generate a magnified (x 2) .png image, but it was not what I expected.

thanks, Randy

from vtk import *

table = vtkTable()
arrX = vtkFloatArray()
arrX.SetName("X")
table.AddColumn(arrX)
arrY = vtkFloatArray()
arrY.SetName("Y")
table.AddColumn(arrY)

table.SetNumberOfRows(2)
table.SetValue(0, 0, 0.0)
table.SetValue(1, 0, 1.0)
table.SetValue(0, 1, 0.0)
table.SetValue(1, 1, 1.0)

view = vtkContextView()

chart = vtkChartXY()
view.GetScene().AddItem(chart)
line = chart.AddPlot(vtkChart.LINE)
line.SetInput(table, 0, 1)

view.GetInteractor().Initialize()
view.GetRenderWindow().SetSize(200,200)

imgFilter = vtkWindowToImageFilter()
imgFilter.SetInput(view.GetRenderWindow())
imgFilter.SetMagnification(2)

writer=vtkPNGWriter()
writer.SetFileName("chart.png")
writer.SetInputConnection(imgFilter.GetOutputPort())
writer.Write()

#view.GetInteractor().Start()


More information about the vtkusers mailing list