Has anyone used log axes in GR?

I tried doing the following:

using GR

x = 1:100
y = abs.(randn(100))
setscale(GR.OPTION_X_LOG)
plot(x,y)
readline()

and no logarithmic x-axis. i thought i was crazy, so i looked for an example that used a log axis and i can’t find a single example that uses a log axis. So I may not be crazy, it might not work…
I also did a simple plot in the REPL and used inqscale to see if it would readback the correct scale, and it does read back a 1, but the plot does not use a logarithmic x-scale.

You should use:

plot(x,y,xlog=true)

You can’t mix low-level and high-level GR functions. I’m aware, that this should be better documented.

ok. I think my main problem is that i see

function plot ( args ::PlotArg…; kv …)

however I can’t find any documentation for the kv, aka “kwargs” arguments, for example i can’t find anything that tells me xlog=true is available. Am I just not finding it or are they undocumented ? I get the impression this is following matlab conventions and maybe i should just look at the matlab plot options to figure it out.

Also I did figure out why repeated plots are slow-ish.

I ran an experiment using polyline and if I call 1000 polylines(), invoking updatews() between each one then things really slow down.

instead, if i simply draw the 1000 polylines, and THEN call updatews() when i’m done the graph appear immediately.

i expect that updatews() is doing a lot more work than i think it is and hence the reason it’s slower.

Thanks again for your help.

I am aware that some things are inadequately documented, which is why the performance of our software is sometimes underestimated. Also the convenience layer has to be revised urgently - hopefully we will find the time soon …

While the official “convenience layer” of GR and its documentation is updated, you may try looking at GRUtils. That is my personal proposal for a redesign of the high-level API of GR, including also more detailed documentation.

Although internals are different, the API of GRUitls mimicks the convenience layer of GR, so in many cases you might be able to make GR plots following the docs of GRUtils (e.g. for tricks like xlog=true, etc), Major departures are reported in https://heliosdrm.github.io/GRUtils.jl/stable/#Relationship-with-GR’s-API-1.

If you want you may also use that package on top of GR, in order to take advantage of some additional functions and keyword arguments.

1 Like