ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 03 Aug 2012 01:05:49 -0500Plotting with logarithmic scaling for the 'x' axis?https://ask.sagemath.org/question/9106/plotting-with-logarithmic-scaling-for-the-x-axis/Hey! Would appreciate very much a bit of help:
I have an Array of data of Positions Vs. Time intervals, where Time goes from 0 to 10000, and every slot on the array represents a time interval of 100. The question is - is there any way to plot the data in the array using List_plot...show(), but with a logarithmic scaled 'x' axis ? Meaning - labels running as - 10^(-4), 10^(-3), ..., 10^5?
Thank you! Sun, 24 Jun 2012 03:14:21 -0500https://ask.sagemath.org/question/9106/plotting-with-logarithmic-scaling-for-the-x-axis/Answer by calc314 for <p>Hey! Would appreciate very much a bit of help: </p>
<p>I have an Array of data of Positions Vs. Time intervals, where Time goes from 0 to 10000, and every slot on the array represents a time interval of 100. The question is - is there any way to plot the data in the array using List_plot...show(), but with a logarithmic scaled 'x' axis ? Meaning - labels running as - 10^(-4), 10^(-3), ..., 10^5? </p>
<p>Thank you! </p>
https://ask.sagemath.org/question/9106/plotting-with-logarithmic-scaling-for-the-x-axis/?answer=13754#post-id-13754There is a ticket for such a thing at [http://ask.sagemath.org/question/675/how-do-i-create-a-log-plot-of-line-data](http://ask.sagemath.org/question/675/how-do-i-create-a-log-plot-of-line-data). From the notes there, it is not quite ready.
You can see the answer to a similar question at [log-log plots](http://ask.sagemath.org/question/675/how-do-i-create-a-log-plot-of-line-data).
Matplotlib has a [LogFormatter](http://matplotlib.sourceforge.net/api/ticker_api.html#matplotlib.ticker.LogFormatter) that you also might be able to use, but I haven't got it working at the moment. It does not appear that using the `tick_formatter` in `show` will let you call this LogFormatter, but I might be missing something here.Sun, 24 Jun 2012 10:28:46 -0500https://ask.sagemath.org/question/9106/plotting-with-logarithmic-scaling-for-the-x-axis/?answer=13754#post-id-13754Comment by kcrisman for <p>There is a ticket for such a thing at <a href="http://ask.sagemath.org/question/675/how-do-i-create-a-log-plot-of-line-data">http://ask.sagemath.org/question/675/how-do-i-create-a-log-plot-of-line-data</a>. From the notes there, it is not quite ready.</p>
<p>You can see the answer to a similar question at <a href="http://ask.sagemath.org/question/675/how-do-i-create-a-log-plot-of-line-data">log-log plots</a>.</p>
<p>Matplotlib has a <a href="http://matplotlib.sourceforge.net/api/ticker_api.html#matplotlib.ticker.LogFormatter">LogFormatter</a> that you also might be able to use, but I haven't got it working at the moment. It does not appear that using the <code>tick_formatter</code> in <code>show</code> will let you call this LogFormatter, but I might be missing something here.</p>
https://ask.sagemath.org/question/9106/plotting-with-logarithmic-scaling-for-the-x-axis/?comment=19511#post-id-19511Actually, http://trac.sagemath.org/sage_trac/ticket/4529 has positive review! Hopefully it will still apply on Sage 5.1. You are right that you have to be a little carefully about the formatters - see the patches at that ticket for more info.Mon, 25 Jun 2012 05:46:08 -0500https://ask.sagemath.org/question/9106/plotting-with-logarithmic-scaling-for-the-x-axis/?comment=19511#post-id-19511Answer by v_2e for <p>Hey! Would appreciate very much a bit of help: </p>
<p>I have an Array of data of Positions Vs. Time intervals, where Time goes from 0 to 10000, and every slot on the array represents a time interval of 100. The question is - is there any way to plot the data in the array using List_plot...show(), but with a logarithmic scaled 'x' axis ? Meaning - labels running as - 10^(-4), 10^(-3), ..., 10^5? </p>
<p>Thank you! </p>
https://ask.sagemath.org/question/9106/plotting-with-logarithmic-scaling-for-the-x-axis/?answer=13889#post-id-13889Since Sage 5.2 it's as simple as
list_plot(data_array, scale='semilogx') # Logarithmic scale for X-axis
list_plot(data_array, scale='semilogy') # Logarithmic scale for Y-axis
list_plot(data_array, scale='loglog') # Logarithmic scale for both axesFri, 03 Aug 2012 01:05:49 -0500https://ask.sagemath.org/question/9106/plotting-with-logarithmic-scaling-for-the-x-axis/?answer=13889#post-id-13889