<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7655.8">
<TITLE>R: [vtkusers] R: Plot XY</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Hi<BR>
Thank you ahead for the interest.<BR>
I used the code that you post me for my project and it works fine but now I have a question:<BR>
How can I change the color of the x and y labels?<BR>
Because I set the background of the blot to white with: renderer->SetBackground (1, 1, 1);<BR>
but now xlabel and ylabel are white and so I want to set these to black; how can I do this?<BR>
<BR>
Thank you very much<BR>
Edoardo Belletti<BR>
<BR>
-----Messaggio originale-----<BR>
Da: Darshan Pai [<A HREF="mailto:darshanpai@gmail.com">mailto:darshanpai@gmail.com</A>]<BR>
Inviato: dom 28/03/2010 23.11<BR>
A: edoardo.belletti@alice.it<BR>
Cc: David Doria; VTK_forum<BR>
Oggetto: Re: [vtkusers] R: Plot XY<BR>
<BR>
You can directly use vtkXYPlotActor to get a plot of 2 arrays .<BR>
<BR>
Here is a simple example to plot a array .<BR>
vtkSmartPointer<vtkXYPlotActor> plot =<BR>
vtkSmartPointer<vtkXYPlotActor>::New();<BR>
plot->ExchangeAxesOff();<BR>
plot->SetLabelFormat( "%g" );<BR>
plot->SetXTitle( "Level" );<BR>
plot->SetYTitle( "Frequency" );<BR>
plot->SetXValuesToIndex();<BR>
<BR>
for ( i = 0 ; i < 2 ; i++)<BR>
{<BR>
vtkSmartPointer<vtkDoubleArray> array_s =<BR>
vtkSmartPointer<vtkDoubleArray>::New();<BR>
vtkSmartPointer<vtkFieldData> field =<BR>
vtkSmartPointer<vtkFieldData>::New();<BR>
vtkSmartPointer<vtkDataObject> data =<BR>
vtkSmartPointer<vtkDataObject>::New();<BR>
<BR>
for (int b = 0; b < 30; b++) /// Assuming an array of 30 elements<BR>
{<BR>
hfile>>val; /// My input is a file .<BR>
array_s->InsertValue(b,val);<BR>
}<BR>
field->AddArray(array_s);<BR>
data->SetFieldData(field);<BR>
plot->AddDataObjectInput(data);<BR>
}<BR>
<BR>
<BR>
plot->SetPlotColor(0,1,0,0);<BR>
plot->SetPlotColor(1,0,1,0);<BR>
<BR>
vtkSmartPointer<vtkRenderer> renderer =<BR>
vtkSmartPointer<vtkRenderer>::New();<BR>
renderer->AddActor(plot);<BR>
renderer->AddActor(rightplot);<BR>
renderer->AddActor(leftplot);<BR>
<BR>
vtkSmartPointer<vtkRenderWindow> renderWindow =<BR>
vtkSmartPointer<vtkRenderWindow>::New();<BR>
renderWindow->AddRenderer( renderer );<BR>
renderWindow->SetSize(1000,1000);<BR>
<BR>
vtkSmartPointer<vtkRenderWindowInteractor> interactor =<BR>
vtkSmartPointer<vtkRenderWindowInteractor>::New();<BR>
interactor->SetRenderWindow( renderWindow );<BR>
<BR>
// Initialize the event loop and then start it<BR>
interactor->Initialize();<BR>
interactor->Start();<BR>
<BR>
<BR>
<BR>
On Sun, Mar 28, 2010 at 2:32 PM, <edoardo.belletti@alice.it> wrote:<BR>
<BR>
> I don't have the latests CVS version of VTK but VTK 5.4.2 that I have<BR>
> download from www.vtk.org<BR>
> and so the code that you suggest me it doesn't work because it don't found<BR>
> these files:<BR>
> vtkChartXY, vtkPlot.h.h, vtkContextView.h, vtkContextScene.h<BR>
> There is some way to simply have a XYPlot of two vectors with my VTK<BR>
> release?<BR>
><BR>
> Thank you<BR>
> Edoardo<BR>
><BR>
> -----Messaggio originale-----<BR>
> Da: daviddoria@gmail.com per conto di David Doria<BR>
> Inviato: dom 28/03/2010 20.10<BR>
> A: edoardo.belletti@alice.it<BR>
> Cc: VTK_forum<BR>
> Oggetto: Re: [vtkusers] Plot XY<BR>
><BR>
><BR>
> On Sun, Mar 28, 2010 at 2:03 PM, <edoardo.belletti@alice.it> wrote:<BR>
><BR>
> > Hello,<BR>
> ><BR>
> > I am new to VTK so please sorry if this problem is obvious.<BR>
> ><BR>
> > I am trying to use the XYPlotActor object to create a simply plot of one<BR>
> > variable against another.<BR>
> ><BR>
> > I have found a piece of code in a past discussion and I have tried to run<BR>
> > it but the problem is that it doesn't found the<BR>
> > vtkFloatScalars.h file<BR>
> > is there anything in particular that I should add in the CMakeLists.txt<BR>
> to<BR>
> > include this library?<BR>
> > the code is this:<BR>
> ><BR>
> > int main()<BR>
> > {<BR>
> > int dataSize = 4;<BR>
> > float x[4] = { 0, 1.5, 6.2, 10.2 };<BR>
> > float y[4] = {8, 9.3, 10.9, 27};<BR>
> > vtkRectilinearGrid *curve1 = vtkRectilinearGrid::New();<BR>
> > curve1->SetDimensions(dataSize,1,1);<BR>
> > vtkFloatScalars *dataValues = vtkFloatScalars::New();<BR>
> > vtkFloatScalars *xCoords = vtkFloatScalars::New();<BR>
> ><BR>
> > int w;<BR>
> > for(w=0; w<dataSize; w++)<BR>
> > {<BR>
> > dataValues->InsertScalar(w, y[w]);<BR>
> > xCoords->InsertScalar(w, x[w]);<BR>
> > }<BR>
> ><BR>
> > curve1->SetXCoordinates(xCoords);<BR>
> > curve1->GetPointData()->SetScalars(dataValues);<BR>
> ><BR>
> > vtkXYPlotActor *theXYPlot = vtkXYPlotActor::New();<BR>
> > theXYPlot->SetXValuesToArcLength();<BR>
> > theXYPlot->AddInput(curve1);<BR>
> > return 0;<BR>
> > }<BR>
> ><BR>
> > Thank you very much for the interest<BR>
> > Edoardo<BR>
> ><BR>
> ><BR>
> > There is no file in the current CVS called vtkFloatScalars.h, so I'm<BR>
> assuming that is very old code.<BR>
><BR>
> Marcus Hanwell has been working hard on new charting functionality - there<BR>
> is a simple example here:<BR>
> <A HREF="http://www.vtk.org/Wiki/VTK_Examples_Chart_XY">http://www.vtk.org/Wiki/VTK_Examples_Chart_XY</A><BR>
><BR>
> You must have the latests CVS version of VTK built to use this new feature.<BR>
> <<A HREF="http://www.vtk.org/Wiki/VTK_Examples_Chart_XY">http://www.vtk.org/Wiki/VTK_Examples_Chart_XY</A>><BR>
> Thanks,<BR>
><BR>
> David<BR>
><BR>
><BR>
> _______________________________________________<BR>
> Powered by www.kitware.com<BR>
><BR>
> Visit other Kitware open-source projects at<BR>
> <A HREF="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</A><BR>
><BR>
> Please keep messages on-topic and check the VTK FAQ at:<BR>
> <A HREF="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</A><BR>
><BR>
> Follow this link to subscribe/unsubscribe:<BR>
> <A HREF="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</A><BR>
><BR>
><BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>