Hi Marco,
It looks to me like for second plot, you created a 792 x 612 page in
Cairo, but told PLplot that the page was 1152 x 528.
Note that you don't update geom between the first and the second plots.
-Hazen
On 03/28/2012 04:50 PM, Quezada, Marco wrote:
> #include<stdio.h>
> #include<unistd.h>
> #include<string>
> #include<cmath>
> #include<iostream>
> #include<sstream>
> #include<cairo.h>
> #include<cairo-pdf.h>
>
> #include<plplot.h>
> #include<plstream.h>
>
> plstream *NewStream(const std::string&outputDriver,
> const std::string&geometry,
> cairo_t *context = NULL)
> {
> // Perform the plplot initialization required by your
> // task.
> plstream *pls = new plstream();
>
> // Re-size the device view surface to the size of the cairo window
> if(geometry != "")
> {
> pls->setopt("geometry", geometry.c_str());
> }
>
> pls->sdev(outputDriver.c_str());
>
> pls->init();
>
> if(context != NULL)
> {
> pls->cmd(PLESC_DEVINIT, context);
> }
>
> pls->adv(0);
>
> pls->vpor(0.1, 0.95, 0.15, 0.9);
>
>
> return(pls);
> }
>
> class Plot
> {
> public:
>
> Plot()
> {
> for(int i = 0; i< 100; ++i)
> {
> xdata[i] = i * ((2.0 * M_PI) / 100.0);
> ydata[i] = sin(xdata[i]) * 100;
> }
> }
>
> void Init()
> {
> pls->clear();
> pls->col0(1);
> pls->wind(0.0, 2.0 * M_PI, -100.0, 100.0);
> pls->box("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
> pls->col0(2);
> pls->box("g", 0.0, 0, "g", 0.0, 0);
> pls->sxax(6, 0);
> pls->syax(6, 0);
> }
>
> void Draw(int I)
> {
> PLFLT *x = xdata;
> PLFLT *y = ydata;
> pls->col0(4);
> pls->line(I, x, y);
>
> pls->flush();
> }
>
> plstream *pls;
> PLFLT xdata[100];
> PLFLT ydata[100];
>
> };
>
> int main( int argc, const char *argv[] )
> {
>
> Plot plot;
>
> double pageW = 1152;
> double pageH = 528;
>
> std::stringstream geom;
> geom<< pageW<< "x"<< pageH;
>
> cairo_surface_t *cs1 = cairo_pdf_surface_create("cairo1.pdf", pageW,
> pageH);
> cairo_t *cairo1 = cairo_create(cs1);
> plstream *pls = NewStream("extcairo", geom.str(), cairo1);
> //plstream *pls = NewStream("xcairo", geom.str());
>
> plot.pls = pls;
> plot.Init();
> pls->col0(2);
> pls->lab("X axis", "Y axis", "Cairo 1");
>
> for(int i = 0; i< 100; ++i)
> {
> plot.Draw(i);
> usleep(10000);
> }
> pls->eop();
> cairo_show_page(cairo1);
> cairo_surface_flush(cs1);
> cairo_destroy(cairo1);
> cairo_surface_destroy(cs1);
>
>
> pageW = 11.0 * 72.0;
> pageH = 8.5 * 72.0;
>
> cairo_surface_t *cs2 = cairo_pdf_surface_create("cairo2.pdf", pageW,
> pageH);
> cairo_t *cairo2 = cairo_create(cs2);
>
> plstream *pls2 = NewStream("extcairo", geom.str(), cairo2);
> //geom.str("");
> //geom<< pageW<< "x"<< pageH;
> //plstream *pls2 = NewStream("xcairo", geom.str());
>
> plot.pls = pls2;
> plot.Init();
> pls2->col0(2);
> pls2->lab("X axis", "Y axis", "Cairo 2");
>
> for(int i = 0; i< 100; ++i)
> {
> plot.Draw(i);
> }
> pls2->eop();
>
> cairo_show_page(cairo2);
> cairo_surface_flush(cs2);
>
> cairo_destroy(cairo2);
> cairo_surface_destroy(cs2);
>
> delete pls;
> delete pls2;
>
> return(0);
> }
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Plplot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-devel