how to save a graph?

328 views
Skip to first unread message

Jian Jiang

unread,
Nov 10, 2018, 5:36:59 PM11/10/18
to VPython-users
Hello all,

I am new with vpython.

Now I am using Spyder. After I run a program includes vpython, the graph and/or animation are display on a window on my browser (google chrome in my case). 

1. Can I save these graphs as e.g. jpg, png... and animations as mp4...? such that I can use them in my PPT later

2. If yes for 1, is there any format can keeep the zoom in/out and rotate function of the graphs generated by vpython?

Thanks inadvance.
Jian
 

Bruce Sherwood

unread,
Nov 10, 2018, 6:05:33 PM11/10/18
to vpytho...@googlegroups.com
1. Simply specify "fast=False" in the graph statement (or in the gcurve or other graphing statement if there is no graph statement). When viewing the graph move the mouse to the upper right and click on the leftmost (camera) button to save the graph to your download folder as a png. When you specify fast=False, the Plotly graphing package is invoked instead of the faster but less capable Flot package.

2. No. However, if you can run your program using GlowScript VPython, at glowscript.org (which you should be able to do unless you import Python modules), it is possible to export the program as JavaScript, which can embedded in a web page. I don't know whether JavaScript can be embeded into a Powerpoint file.

Bruce

Jian Jiang

unread,
Nov 11, 2018, 8:24:07 AM11/11/18
to VPython-users
Hi Bruce,

Thanks for your reply.

After I added the 'fast=False', the program still worked, but nothing is different of the picture I can get in the browser, namely no button on the graph.

I attached my code, and what I can see in the browser below.

Thanks.
Jian
vpythontest.py
Capture.PNG

Bruce Sherwood

unread,
Nov 11, 2018, 9:45:34 AM11/11/18
to VPython-users
You asked about "graph", which in VPython is a 2D xy mathematical object with labeled axes.

For 3D graphics in a "canvas", currently there isn't a way to capture an image other than by using screen capture, as you did to make Capture.PNG.

Bruce

Jian Jiang

unread,
Nov 11, 2018, 9:49:26 AM11/11/18
to VPython-users
understood,

THX
Reply all
Reply to author
Forward
0 new messages