2021-02-22 02:31:16 +0200 received badge ● Famous Question (source) 2019-09-05 17:22:12 +0200 received badge ● Notable Question (source) 2018-04-30 22:17:24 +0200 received badge ● Famous Question (source) 2017-04-11 03:28:55 +0200 received badge ● Popular Question (source) 2017-02-17 23:38:52 +0200 received badge ● Popular Question (source) 2017-02-17 23:38:52 +0200 received badge ● Notable Question (source) 2015-11-18 02:06:23 +0200 commented question Save plots into a multi-page pdf? Thanks for replying. Yes, it was an admittedly naive attempt to see if the PdfPages import would work as-is, and I didn't really expect it would. Now I'm hunting around to see if there's any other way of achieving the same result. If not, it's easy enough to create a pdf from individual plot images. 2015-11-17 13:24:36 +0200 asked a question Save plots into a multi-page pdf? I am creating a series of plots that I would like to save into a multi-page pdf file. I found a couple of references about using matplotlib in pylab to do so, but I can't get it to work in SageMath. Is it possible to do this in SageMath? Here's what I tried: from matplotlib.backends.backend_pdf import PdfPages pdf_pages = PdfPages('curves.pdf') p1, p1max, p2, p2max, a = var('p1, p1max, p2, p2max, a') p1max = 10 p2max = 10 for p1 in [1..p1max]: for p2 in [1..p2max]: fig = parametric_plot([cos(a) + cos(p1*a)/2 + sin(p2*a)/3, sin(a) + sin(p1*a)/2 + cos(p2*a)/3], (a, 0, 2 * pi), title = ('(p1, p2) = (' + str(p1) + ', ' + str(p2) + ')'), frame = True, axes_pad = .05) pdf_pages.savefig(fig) pdf_pages.close()  ... and it produces this error: File "/usr/lib/sagemath/local/lib/python2.7/site-packages/matplotlib-1.4.3-py2.7-linux-x86_64.egg/matplotlib/backends/backend_pdf.py", line 2438, in savefig raise ValueError("No such figure: " + repr(figure)) ValueError: No such figure: Graphics object consisting of 1 graphics primitive  2015-11-16 14:34:15 +0200 received badge ● Nice Question (source) 2015-11-16 14:04:53 +0200 received badge ● Student (source) 2015-11-15 22:04:53 +0200 commented answer Error when using 'for in range()' but not ' for in [..]' Ah, that explains it, thank you. I had read that the Python interpreter would automatically cast the integers to floats when dividing, but I now realise that was referring to Python 3, and I am using Python 2.7. 2015-11-15 17:33:12 +0200 asked a question Error when using 'for in range()' but not ' for in [..]' I've just started using SageMath today, and I've been pleasantly surprised at how good it is. I've been working through tutorials and playing around with plotting functions without any major problems until I wrote a series of nested for-loops using range values. I'm getting the error 'ValueError("plot start point and end point must be different")', but only when the outer loop uses 'for r1 in range(3,6)', not when I do exactly the same thing using 'for r1 in [3..5]'. Am I doing something newbie-naive here, or is this a bug? Here's the full script: t = var('t') g = Graphics() for r1 in [3..5]: # This works as expected #for r1 in range(3,6): # This produces error: File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/plot/misc.py", line 136, in setup_for_eval_on_grid raise ValueError("plot start point and end point must be different") g = g + circle((0, 0), r1, rgbcolor=(0.5,0.5,0.5)) for r2 in range(1, r1): f = floor((r1 + r2) / 2) for d in range(1, f): print "r1 =",r1, " r2 =", r2, " d =",d; # debug msg g = g + parametric_plot(((r1 - r2) * cos(t) + d * cos((r1 - r2) * t / r2), (r1 - r2) * sin(t) - d * sin((r1 - r2) * t / r2)), (t, 0, r2 / r1 * (pi ^ pi)), rgbcolor=(r2/r1, d / f, 0.5)) g.show()