# How do I create a log plot of line data?

Is there a good way to create a log-log plot of line data in sage? I can't find it through the plot or line interfaces.

How do I create a log plot of line data?

3

You could rescale the data before you plot it:

```
sage: data = [(t^2,t^3) for t in srange(1,10,.1)]
sage: L = line2d(data)
sage: L.show(figsize=[5,2])
```

```
sage: log_data = [(log(x[0]),log(x[1])) for x in data]
sage: M = line2d(log_data)
sage: M.show(figsize=[5,2])
```

If you want the tick marks to be logarithmic, the docstring for `M.show`

describes an option for using a matplotlib tick "locator".

```
sage: from matplotlib import ticker
sage: tloc = lambda m: ticker.LogLocator(subs=[m])
sage: M.show(figsize=[5,2],ticks=(tloc(4),tloc(1)))
```

To be honest though, I had a lot of trouble using the `LogLocator`

-- it doesn't seem completely polished, and may take a while to understand.

Hey, this seems to give nice results in terms of the shape of the graphs, but I don't get lables on the 'X' axis this way so I can't tell... Even in your example, change the - 4 in the 'tloc(4)' to 10 , and u don't get any lables, ('2' will give you only one lable , for - 0.2)...

Hey, this seems to give nice results in terms of the shape of the graphs, but I don't get lables on the 'X' axis this way so I can't tell... Even in your example, change the - 4 in the 'tloc(4)' to 10 , and u don't get any lables, ('2' will give you only one lable , for - 0.2)...

Please start posting anonymously - your entry will be published after you log in or create a new account.

Asked: ** 2011-07-26 18:54:24 +0200 **

Seen: **1,706 times**

Last updated: **Jul 27 '11**

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.

Sadly not yet - this is an often-requested thing - see http://trac.sagemath.org/sage_trac/ticket/4529. Niles' answers are as good as any.

Update - this ticket has positive review, and hopefully will be in Sage 5.2.