Skip to content

How to "exit" or close gnuplot? #251

Answered by alandefreitas
jdnec asked this question in Q&A
Discussion options

You must be logged in to vote

Don't call auto fig5 = matplot::figure(true); inside the loop. By creating a new figure, you're asking the backend to launch another instance of gnuplot to plot that chart.

Just create the figure outside the loop and use the loop to update the figure:

auto fig = matplot::figure(true);
for (int i=0; i<1000; i++)
{                                   
                                fig->position({ 560, 1, 0, 0 });
                                fig->size(1920, 980);
                                fig->plot( x, y, x, z);
                                fig->save("temp/image.jpg");
                               // figures destroyed with RAII when the handle gets invalidated
}

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@jdnec
Comment options

@alandefreitas
Comment options

@jdnec
Comment options

Comment options

You must be logged in to vote
1 reply
@jdnec
Comment options

Answer selected by alandefreitas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants