Newbie plotting frustration

Hi All,
I have been developing a significant level of frustration over the past few weeks. On one hand, Julia appears fast and able to deal with the data that I need to deal with, at least up to a point. Documentation and web search are great.

On the other, while modules such as Plots, Makie & AlgebraOfGraphics (to name three) can produce some spectacular output, I am yet to be able to produce something simple like a plot with Log10 axes with major ticks as powers of 10 and minor ticks correctly positioned (or at all …). Even being able to specify the locations of minor tick marks would be something. At least then I could roll my own plot.

And that’s before getting to the real goal of plotting +ve data as solid lines and -ve data as dashed lines. Kluges like asinh scaling seem not to work. And yes, I know that -ve Log10 is complex. That doesn’t help with measurements that have a large dynamic range and data polarity is significant.

Assuming I am not wasting my time pursuing this goal in Julia, is there a simple example or tutorial that anyone would like to suggest?

ManyTIA – D.

2 Likes

Hey there! I’ve also been exploring different plotting frameworks in Julia recently. Coming from ggplot2, the transition has been challenging, mainly because of how mature and well-integrated that ecosystem is. That said, TidierPlots.jl has been improving a lot, and its documentation is getting better as well and could be a bridge between these two worlds.

On the other hand, I see AlgebraOfGraphics as a sort of evolution of ggplot2, offering cleaner approach to data visualization IMHO. The documentation recently received a major overhaul, making it much easier to get started. I also came across a somewhat hidden but useful series of tutorials on AoG that you might find helpful!

Also, remember to reach out the community or open an issue, people are usually keen to help.

3 Likes

Brilliant!
Many thanks Camilo. It seems that I may have overlooked TidierPlots as one of the examples suggests that this module may be worthwhile pursuing.
D.

3 Likes

I mainly use PyPlot.jl . It allows you to use (nearly) the Matplotlib syntax, which is well documented and feature rich.

For real-time 3D plots I use Makie.jl .

Honestly, having a matlab and python background, I found julia plotting packages easy to use. My goto package is Makie.jl. The documentation, associated to beauiful Makie, is really great.

And you can always post your questions here :wink:

2 Likes

I had a similar experience, maybe something like this:

plot(x, y;
     xscale     = :log10,
     xticks     = 10 .^ collect(0:ceil(log10(x))),
     minorticks = 10)

I also find Makie.jl to be my favourite plotting package in Julia.
In a way it’s pretty similar to how base R plots work, but much easier to customize.

https://beautiful.makie.org/ has many examples - some of which also feature the log axes requested in the original post: see here.

1 Like

Here’s four different variants with Makie, same thing applies to AlgebraOfGraphics:

f = Figure()
scatter(f[1, 1], 1:100; axis = (;
    yscale = log10,
    yminorticksvisible = true,
    yminorticks = IntervalsBetween(10),
))
scatter(f[1, 2], 1:100; axis = (;
    yscale = log10,
    yminorticksvisible = true,
    yminorticks = IntervalsBetween(5),
))
scatter(f[2, 1], 1:100; axis = (;
    yscale = log10,
    yminorticksvisible = true,
    yticks = [1, 10, 100],
    yminorticks = IntervalsBetween(10),
))
scatter(f[2, 2], 1:100; axis = (;
    yscale = log10,
    yminorticksvisible = true,
    yticks = [1, 10, 100],
    yminorticks = [2, 5, 20, 50],
))
f

And without giving it a lot of thought, this asinh implementation looks fine at first glance, but you have to supply better ticks as no tick finder overload exists for this specific combination, yet.

scatter(-100:2:100; axis = (;
    yscale = ReversibleScale(
        asinh,
        sinh,
    ),
))

3 Likes

Are logarithmic grid lines possible with Makie? Like this?

This was created with ControlPlots.jl which is based on PyPlot…

Sure, they are just disabled in the default theme (my examples above had the AoG theme applied unintentionally):

f = Figure(Axis = (; yminorgridvisible = true, yminorgridcolor = :gray90))

scatter(f[1, 1], 1:100; axis = (;
    yscale = log10,
    yminorticksvisible = true,
    yminorticks = IntervalsBetween(10),
))
scatter(f[1, 2], 1:100; axis = (;
    yscale = log10,
    yminorticksvisible = true,
    yminorticks = IntervalsBetween(5),
))
scatter(f[2, 1], 1:100; axis = (;
    yscale = log10,
    yminorticksvisible = true,
    yticks = [1, 10, 100],
    yminorticks = IntervalsBetween(10),
))
scatter(f[2, 2], 1:100; axis = (;
    yscale = log10,
    yminorticksvisible = true,
    yticks = [1, 10, 100],
    yminorticks = [2, 5, 20, 50],
))
f

5 Likes

Many thanks to all for contributing to this thread. I felt sure that such a simple problem had been solved, but just couldn’t see it in the array of seemingly different options.
For the record, I’m coming from Mathematica where I’d use SciDraw to solve this problem.
Also for the record, assuming df_r has been read & populated, the code

fig = Figure(; size=(1000, 300))
ax = Axis(fig[1, 1], 
    xlabel="Easting (m)", ylabel="Inphase (ppm)",
    yscale=log10,
    yminorticksvisible=true, yminorticks=IntervalsBetween(9),
    xtickformat = "{:.0f}", 
    xminorticksvisible=true, xminorticks=IntervalsBetween(9)
)
scatterlines!(df_r.Mid_E, ifelse.(df_r.FI_01 .> 0, abs.(df_r.FI_01), NaN); color=:blue, linestyle=:solid, markersize=0)
scatterlines!(df_r.Mid_E, abs.(df_r.FI_01); color=:blue, linestyle=:dash, markersize=0)
xlims!(418500,433500)
ylims!(.1, 10000)

fig

produces the desired panel which is


with labelling to be added.

1 Like