ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 21 Nov 2011 17:48:02 +0100Creating a semilogx (or semilogy or loglog) plothttps://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/I would like to create a semilogx plot of some data. I have two lists of data and would like to use something like list_plot() to visualize the data, but the x-axis should be logarithmic. I have attempted (and failed) in using pyplot, but get an error message like this:
Your currently selected backend, 'agg' does not support show().
Please select a GUI backend in your matplotlibrc file
which I don't understand. Is there an option to plot() and/or list_plot() that allows one to choose logarithmic axes?
Thanks.Sun, 20 Nov 2011 19:05:20 +0100https://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/Comment by DSM for <p>I would like to create a semilogx plot of some data. I have two lists of data and would like to use something like list_plot() to visualize the data, but the x-axis should be logarithmic. I have attempted (and failed) in using pyplot, but get an error message like this:</p>
<pre><code>Your currently selected backend, 'agg' does not support show().
Please select a GUI backend in your matplotlibrc file
</code></pre>
<p>which I don't understand. Is there an option to plot() and/or list_plot() that allows one to choose logarithmic axes?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/?comment=20841#post-id-20841@kcrisman-- ah, the unintended consequence of generosity..Mon, 21 Nov 2011 17:48:02 +0100https://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/?comment=20841#post-id-20841Comment by Ed Scheinerman for <p>I would like to create a semilogx plot of some data. I have two lists of data and would like to use something like list_plot() to visualize the data, but the x-axis should be logarithmic. I have attempted (and failed) in using pyplot, but get an error message like this:</p>
<pre><code>Your currently selected backend, 'agg' does not support show().
Please select a GUI backend in your matplotlibrc file
</code></pre>
<p>which I don't understand. Is there an option to plot() and/or list_plot() that allows one to choose logarithmic axes?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/?comment=20847#post-id-20847Thanks to Benjamin Jones. This answer was very helpful and I was able to produce the figure I needed!Mon, 21 Nov 2011 11:13:16 +0100https://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/?comment=20847#post-id-20847Comment by kcrisman for <p>I would like to create a semilogx plot of some data. I have two lists of data and would like to use something like list_plot() to visualize the data, but the x-axis should be logarithmic. I have attempted (and failed) in using pyplot, but get an error message like this:</p>
<pre><code>Your currently selected backend, 'agg' does not support show().
Please select a GUI backend in your matplotlibrc file
</code></pre>
<p>which I don't understand. Is there an option to plot() and/or list_plot() that allows one to choose logarithmic axes?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/?comment=20842#post-id-20842@DSM: Except that someone community wiki'ed it, so it won't ;-)Mon, 21 Nov 2011 16:46:14 +0100https://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/?comment=20842#post-id-20842Comment by DSM for <p>I would like to create a semilogx plot of some data. I have two lists of data and would like to use something like list_plot() to visualize the data, but the x-axis should be logarithmic. I have attempted (and failed) in using pyplot, but get an error message like this:</p>
<pre><code>Your currently selected backend, 'agg' does not support show().
Please select a GUI backend in your matplotlibrc file
</code></pre>
<p>which I don't understand. Is there an option to plot() and/or list_plot() that allows one to choose logarithmic axes?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/?comment=20846#post-id-20846@Ed Scheinerman: if the answer helped, you should click the button to "accept the answer". This helps us keep track of unanswered questions and gives him some extra karma to boot. :-)Mon, 21 Nov 2011 11:56:01 +0100https://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/?comment=20846#post-id-20846Answer by kcrisman for <p>I would like to create a semilogx plot of some data. I have two lists of data and would like to use something like list_plot() to visualize the data, but the x-axis should be logarithmic. I have attempted (and failed) in using pyplot, but get an error message like this:</p>
<pre><code>Your currently selected backend, 'agg' does not support show().
Please select a GUI backend in your matplotlibrc file
</code></pre>
<p>which I don't understand. Is there an option to plot() and/or list_plot() that allows one to choose logarithmic axes?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/?answer=12926#post-id-12926This is not an answer, so don't upvote it - but just for reference, doing a better job with this is [Ticket 4529](http://trac.sagemath.org/sage_trac/ticket/4529).Mon, 21 Nov 2011 16:44:39 +0100https://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/?answer=12926#post-id-12926Answer by benjaminfjones for <p>I would like to create a semilogx plot of some data. I have two lists of data and would like to use something like list_plot() to visualize the data, but the x-axis should be logarithmic. I have attempted (and failed) in using pyplot, but get an error message like this:</p>
<pre><code>Your currently selected backend, 'agg' does not support show().
Please select a GUI backend in your matplotlibrc file
</code></pre>
<p>which I don't understand. Is there an option to plot() and/or list_plot() that allows one to choose logarithmic axes?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/?answer=12924#post-id-12924The easiest thing to do right now is follow Niles' advice in this question:
[How do I create a log plot](http://ask.sagemath.org/question/675/how-do-i-create-a-log-plot-of-line-data)
Basically, apply the logarithm to your data explicitly and list plot that. You can also change the way ticks are displayed on the axes to make it clear that it's a log plot.
Regarding `pyplot`, you can still use it but since it is a matplotlib module, the Sage wrappers are not in place to take it's output and display it to you through Sage (unless you do some tweaking to the matplotlib package that ships with Sage --someone correct me if I'm wrong here).
What you can do is call pyplot and have the image saved to a file and view it yourself, e.g.:
# stolen from: http://matplotlib.sourceforge.net/examples/pylab_examples/log_demo.html
import numpy as np
import matplotlib.pyplot as plt
plt.subplots_adjust(hspace=0.4)
t = np.arange(0.01, 20.0, 0.01)
# log x and y axis
plt.subplot(111)
plt.loglog(t, 20*np.exp(-t/10.0), basex=10)
plt.grid(True)
plt.title('loglog base 10 on x')
plt.savefig('foo.png')
If I execute this code in the Sage notebook, I see a nice log plot. In command line Sage, you would get a file saved to disk.Sun, 20 Nov 2011 20:31:25 +0100https://ask.sagemath.org/question/8497/creating-a-semilogx-or-semilogy-or-loglog-plot/?answer=12924#post-id-12924