Extend plot support for entanglementplot and transferplot to Makie.jl - #428
borisdevos wants to merge 33 commits into
Conversation
lkdvos
left a comment
There was a problem hiding this comment.
This definitely looks great!
I have a couple questions, mostly since it has been a while since I looked at Makie:
Do you know if the other attributes can still be set/changed? For example, what happens if I want to override the default title/ticks/...?
I seem to recall also that there was some system with observables etc, where various parts where dynamically recalculated. Do you know if this is still relevant?
| Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" | ||
| Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" | ||
| BlockTensorKit = "5f87ffc2-9cf1-4a46-8172-465d160bd8cd" | ||
| CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" |
There was a problem hiding this comment.
This should probably be a weakdep?
| DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" | ||
| HalfIntegers = "f0d1745a-41c9-11e9-1dd9-e5d34d218721" | ||
| KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77" | ||
| LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" |
There was a problem hiding this comment.
Does this make sense to have as a default dependency? We could in principle also have a default xlabel that uses Unicode, and require people that wish Latex strings to specify the xlabel themselves (which I would assume people typically want anyways)
There was a problem hiding this comment.
At least for Makie I could keep the default latexstring expressions and put it as a weakdep, since it's explicitly in the deps of Makie. I put it here in deps to get it working for Plots, but we can indeed default to whatever and let the user overwrite themselves (if possible for Plots, I think I've got it working for Makie right now)
|
I don't understand the current aqua test failing. It seems to be complaining about missing compat bounds for every package under extras of the main project.toml (but are specified in the test project.toml), but this previously wasn't failing. |
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
…ng for in-place methods
|
Okay, I finally managed to look into this again. I'm happy with how things are in terms of being able to use these backends with some customisation. What remains is some stylistic decisions. In particular, I don't know how useful it is to plot transfer matrix spectra the way we are now. These phases don't matter in many cases, so if we allow some toggle to not plot them, there's then a way to plot the different sectors next to each other, similar to the current entanglement plots. Some other style choices are in todos, though I'm sure there are many more. |
| #TODO: remove once the recipes publish their axis attributes instead of setting them | ||
| function with_current_axis(f, target) | ||
| target isa Makie.AbstractAxis || return f() | ||
| previous = Makie.current_axis() | ||
| Makie.current_axis!(target) | ||
| try | ||
| return f() | ||
| finally | ||
| isnothing(previous) || Makie.current_axis!(previous) | ||
| end | ||
| end | ||
|
|
||
| # overwrite user-provided axis attributes | ||
| function apply_plotkwargs!(ax, plotkwargs) | ||
| ax isa Makie.AbstractAxis || return ax | ||
| for (k, v) in pairs(plotkwargs) | ||
| setproperty!(ax, k, v) | ||
| end | ||
| return ax | ||
| end |
There was a problem hiding this comment.
This looks a little backwards, I feel like it should be possible to make the attributes respect what was provided, and somehow it feels like we are doing too much work with providing ticks etc, for which there should just be a default that is sensible and otherwise user-overridable?
There was a problem hiding this comment.
So this part of the code exists to deal with the in-place versions of the plot functions, but you want these things to be attributes of the default?
The workaround here was because some of the default attributes I set are of the axis, and not of the scatter plot itself. I looked at the whole ComputeGraph machinery you once mentioned to me, and I think that's exactly you want. I'll try this out
|
|
||
| ax.ylabel = L"\log(\lambda)" | ||
| ax.ylabelsize = 24 | ||
| smallest = minimum(Iterators.filter(>(0), Iterators.flatten(spectrum)); init = 1.0) # safety net |
There was a problem hiding this comment.
Does this mean that we are effectively hiding pathological cases? Do you think there is a way of still showing them so we can diagnose the issue?
There was a problem hiding this comment.
I can filter on ==0, give a warning but still plot the way it is currently?


Deals with #249. This works locally, below I attach the results for both Plots.jl and CairoMakie.jl*. I didn't really test any other Makie backend, but I think CairoMakie is the one you want anyways in this context.
As you can see in the attachment, I didn't really bother to make the
Plots.jlplots any prettier than they were, and they remain equally blurry. Anyone willing to prettify these, feel free to do so. I put slightly more effort in the Makie plots, but even there plenty of improvements can be added.I added todo's here and there, mostly stylistic choices.
*There are two plots per function, just to show that keyword arguments are being taken correctly:
someplots.pdf