<!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-&gt;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&lt;vtkXYPlotActor&gt; plot =<BR>
vtkSmartPointer&lt;vtkXYPlotActor&gt;::New();<BR>
&nbsp;&nbsp;&nbsp; plot-&gt;ExchangeAxesOff();<BR>
&nbsp;&nbsp;&nbsp; plot-&gt;SetLabelFormat( &quot;%g&quot; );<BR>
&nbsp;&nbsp;&nbsp; plot-&gt;SetXTitle( &quot;Level&quot; );<BR>
&nbsp;&nbsp;&nbsp; plot-&gt;SetYTitle( &quot;Frequency&quot; );<BR>
&nbsp;&nbsp;&nbsp; plot-&gt;SetXValuesToIndex();<BR>
<BR>
for ( i = 0 ; i &lt; 2 ; i++)<BR>
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;vtkDoubleArray&gt; array_s =<BR>
vtkSmartPointer&lt;vtkDoubleArray&gt;::New();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;vtkFieldData&gt; field =<BR>
vtkSmartPointer&lt;vtkFieldData&gt;::New();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;vtkDataObject&gt; data =<BR>
vtkSmartPointer&lt;vtkDataObject&gt;::New();<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int b = 0; b &lt; 30; b++)&nbsp;&nbsp; /// Assuming an array of 30 elements<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hfile&gt;&gt;val;&nbsp;&nbsp; /// My input is a file .<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; array_s-&gt;InsertValue(b,val);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; field-&gt;AddArray(array_s);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data-&gt;SetFieldData(field);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; plot-&gt;AddDataObjectInput(data);<BR>
}<BR>
<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; plot-&gt;SetPlotColor(0,1,0,0);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; plot-&gt;SetPlotColor(1,0,1,0);<BR>
<BR>
&nbsp;vtkSmartPointer&lt;vtkRenderer&gt; renderer =<BR>
vtkSmartPointer&lt;vtkRenderer&gt;::New();<BR>
&nbsp; renderer-&gt;AddActor(plot);<BR>
&nbsp; renderer-&gt;AddActor(rightplot);<BR>
&nbsp; renderer-&gt;AddActor(leftplot);<BR>
<BR>
&nbsp; vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow =<BR>
vtkSmartPointer&lt;vtkRenderWindow&gt;::New();<BR>
&nbsp; renderWindow-&gt;AddRenderer( renderer );<BR>
&nbsp; renderWindow-&gt;SetSize(1000,1000);<BR>
<BR>
&nbsp; vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; interactor =<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();<BR>
&nbsp; interactor-&gt;SetRenderWindow( renderWindow );<BR>
<BR>
&nbsp; // Initialize the event loop and then start it<BR>
&nbsp; interactor-&gt;Initialize();<BR>
&nbsp; interactor-&gt;Start();<BR>
<BR>
<BR>
<BR>
On Sun, Mar 28, 2010 at 2:32 PM, &lt;edoardo.belletti@alice.it&gt; wrote:<BR>
<BR>
&gt;&nbsp; I don't have the latests CVS version of VTK but VTK 5.4.2 that I have<BR>
&gt; download from www.vtk.org<BR>
&gt; and so the code that you suggest me it doesn't&nbsp; work because it don't found<BR>
&gt; these files:<BR>
&gt; vtkChartXY, vtkPlot.h.h, vtkContextView.h, vtkContextScene.h<BR>
&gt; There is some way to simply have a XYPlot of two vectors with my VTK<BR>
&gt; release?<BR>
&gt;<BR>
&gt; Thank you<BR>
&gt; Edoardo<BR>
&gt;<BR>
&gt; -----Messaggio originale-----<BR>
&gt; Da: daviddoria@gmail.com per conto di David Doria<BR>
&gt; Inviato: dom 28/03/2010 20.10<BR>
&gt; A: edoardo.belletti@alice.it<BR>
&gt; Cc: VTK_forum<BR>
&gt; Oggetto: Re: [vtkusers] Plot XY<BR>
&gt;<BR>
&gt;<BR>
&gt; On Sun, Mar 28, 2010 at 2:03 PM, &lt;edoardo.belletti@alice.it&gt; wrote:<BR>
&gt;<BR>
&gt; &gt;&nbsp;&nbsp; Hello,<BR>
&gt; &gt;<BR>
&gt; &gt; I am new to VTK so please sorry if this problem is obvious.<BR>
&gt; &gt;<BR>
&gt; &gt; I am trying to use the XYPlotActor object to create a simply plot of one<BR>
&gt; &gt; variable against another.<BR>
&gt; &gt;<BR>
&gt; &gt; I have found a piece of code in a past discussion and I have tried to run<BR>
&gt; &gt; it but the problem is that it doesn't found the<BR>
&gt; &gt; vtkFloatScalars.h file<BR>
&gt; &gt; is there anything in particular that I should add in the CMakeLists.txt<BR>
&gt; to<BR>
&gt; &gt; include this library?<BR>
&gt; &gt; the code is this:<BR>
&gt; &gt;<BR>
&gt; &gt; int main()<BR>
&gt; &gt; {<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int dataSize = 4;<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float x[4] = { 0, 1.5, 6.2, 10.2 };<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float y[4] = {8, 9.3, 10.9, 27};<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkRectilinearGrid *curve1 = vtkRectilinearGrid::New();<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; curve1-&gt;SetDimensions(dataSize,1,1);<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkFloatScalars *dataValues = vtkFloatScalars::New();<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkFloatScalars *xCoords = vtkFloatScalars::New();<BR>
&gt; &gt;<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int w;<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(w=0; w&lt;dataSize; w++)<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataValues-&gt;InsertScalar(w, y[w]);<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xCoords-&gt;InsertScalar(w, x[w]);<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&gt; &gt;<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; curve1-&gt;SetXCoordinates(xCoords);<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; curve1-&gt;GetPointData()-&gt;SetScalars(dataValues);<BR>
&gt; &gt;<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkXYPlotActor *theXYPlot = vtkXYPlotActor::New();<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; theXYPlot-&gt;SetXValuesToArcLength();<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; theXYPlot-&gt;AddInput(curve1);<BR>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<BR>
&gt; &gt; }<BR>
&gt; &gt;<BR>
&gt; &gt; Thank you very much for the interest<BR>
&gt; &gt; Edoardo<BR>
&gt; &gt;<BR>
&gt; &gt;<BR>
&gt; &gt; There is no file in the current CVS called vtkFloatScalars.h, so I'm<BR>
&gt; assuming that is very old code.<BR>
&gt;<BR>
&gt; Marcus Hanwell has been working hard on new charting functionality - there<BR>
&gt; is a simple example here:<BR>
&gt; <A HREF="http://www.vtk.org/Wiki/VTK_Examples_Chart_XY">http://www.vtk.org/Wiki/VTK_Examples_Chart_XY</A><BR>
&gt;<BR>
&gt; You must have the latests CVS version of VTK built to use this new feature.<BR>
&gt; &lt;<A HREF="http://www.vtk.org/Wiki/VTK_Examples_Chart_XY">http://www.vtk.org/Wiki/VTK_Examples_Chart_XY</A>&gt;<BR>
&gt; Thanks,<BR>
&gt;<BR>
&gt; David<BR>
&gt;<BR>
&gt;<BR>
&gt; _______________________________________________<BR>
&gt; Powered by www.kitware.com<BR>
&gt;<BR>
&gt; Visit other Kitware open-source projects at<BR>
&gt; <A HREF="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</A><BR>
&gt;<BR>
&gt; Please keep messages on-topic and check the VTK FAQ at:<BR>
&gt; <A HREF="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</A><BR>
&gt;<BR>
&gt; Follow this link to subscribe/unsubscribe:<BR>
&gt; <A HREF="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</A><BR>
&gt;<BR>
&gt;<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>