Replies: 7 comments
-
You can probably specify an That's how we do it in MakieThemes, here: |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply. However, that doesn't quite seem to work. This is what I tried: struct MyType
end
function AbstractPlotting.default_theme(scene::SceneLike, ::Type{<: Plot(MyType)})
Theme( textsize = 6,
axis2d = Theme(frame = Theme(linewidth= 1.5,
frames = ((true, false), (false, false))),
grid = Theme(linewidth = (0, 0)),
names = Theme(axisnames = ("Time", "Activity")))
)
end
function AbstractPlotting.plot!(p::Plot(MyType))
x = range(0.0, stop=1.0, length=10)
y = x.^2
lines!(p, x,y)
end
Q = MyType()
p = plot(Q)
@test p[Axis][:frame, :frames][] == ((true, false), (false, false)) The test fails with the following: Test Failed at /Users/roger/Documents/programming/julia/NeuralPlots/test/runtests.jl:29
Expression: ((p[Axis])[:frame, :frames])[] == ((true, false), (false, false))
Evaluated: ((false, false), (false, false)) == ((true, false), (false, false)) |
Beta Was this translation helpful? Give feedback.
-
Oh, it might be the scene attributes problem again. There is a way to fix that but it's a tad hacky -basically you capture the relevant attributes and add them to the scene within the plotting pipeline.
|
Beta Was this translation helpful? Give feedback.
-
I started out following the molecular simulation tutorial, which does not use the @recipe macro directly (at least last time I checked). Also, if i understand things correctly, the @recipe macro is mainly used to define new types of plots, while my idea was to write a specialised plot function for my type, so that I can just write plot(MyType) and have it create a plot, e.g. a line plot, but formatted for my type. I think this is how I used to use the recipe framework in Plots.jl |
Beta Was this translation helpful? Give feedback.
-
Also, is there code somewhere showing the hacky solution in action? : ) |
Beta Was this translation helpful? Give feedback.
-
Unfortunately not, that hack is made deep in the bowels of the plotting pipeline...there was a commit touching that code a little while ago. |
Beta Was this translation helpful? Give feedback.
-
@SimonDanisch, sorry to keep pinging you on this, but it would be cool if this was a feature in higher-level recipes. |
Beta Was this translation helpful? Give feedback.
-
I'm sure this is very obvious, but I just can't wrap my head around it. I am following the molecular simulation recipe that create a plot function for my own type. My question is how do I, through the type recipe formalism, specify e.g. axis names? There doesn't seem to be a way to get the axis object from the AbstractPlotting.plot! function that I am overriding for my type. Naively, I would want to insert something like this in my function
but this gives me a
MethodError
sayingWhat is the proper way of overriding Axis attributes for a custom type?
Beta Was this translation helpful? Give feedback.
All reactions