Skip to content

Commit 81a5ceb

Browse files
committed
update recipes attributes
1 parent eae320e commit 81a5ceb

File tree

1 file changed

+116
-18
lines changed

1 file changed

+116
-18
lines changed

src/Recipes.jl

Lines changed: 116 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,101 @@
1+
function smithplot_attributes()
2+
Makie.@DocumentedAttributes begin
3+
"The color of the line."
4+
color = @inherit linecolor
5+
"Sets the width of the line in screen units"
6+
linewidth = @inherit linewidth
7+
"""
8+
Sets the dash pattern of the line. Options are `:solid` (equivalent to `nothing`), `:dot`, `:dash`, `:dashdot` and `:dashdotdot`.
9+
These can also be given in a tuple with a gap style modifier, either `:normal`, `:dense` or `:loose`.
10+
For example, `(:dot, :loose)` or `(:dashdot, :dense)`.
11+
12+
"""
13+
linestyle = nothing
14+
"""
15+
Sets the type of line cap used. Options are `:butt` (flat without extrusion),
16+
`:square` (flat with half a linewidth extrusion) or `:round`.
17+
"""
18+
linecap = @inherit linecap
19+
"""
20+
Controls the rendering at corners. Options are `:miter` for sharp corners,
21+
`:bevel` for "cut off" corners, and `:round` for rounded corners. If the corner angle
22+
is below `miter_limit`, `:miter` is equivalent to `:bevel` to avoid long spikes.
23+
"""
24+
joinstyle = @inherit joinstyle
25+
"Sets the minimum inner join angle below which miter joins truncate. See also `Makie.miter_distance_to_angle`."
26+
miter_limit = @inherit miter_limit
27+
"""
28+
Sets which attributes to cycle when creating multiple plots. The values to
29+
cycle through are defined by the parent Theme. Multiple cycled attributes can
30+
be set by passing a vector. Elements can
31+
- directly refer to a cycled attribute, e.g. `:color`
32+
- map a cycled attribute to a palette attribute, e.g. `:linecolor => :color`
33+
- map multiple cycled attributes to a palette attribute, e.g. `[:linecolor, :markercolor] => :color`
34+
"""
35+
cycle = [:color]
36+
mixin_generic_plot_attributes()...
37+
mixin_colormap_attributes()...
38+
fxaa = false
39+
end
40+
end
41+
42+
function smithscatter_attributes()
43+
Makie.@DocumentedAttributes begin
44+
"Sets the color of the marker. If no color is set, multiple calls to `scatter!` will cycle through the axis color palette."
45+
color = @inherit markercolor
46+
"Sets the scatter marker."
47+
marker = @inherit marker
48+
"""
49+
Sets the size of the marker by scaling it relative to its base size which can differ for each marker.
50+
A `Real` scales x and y dimensions by the same amount.
51+
A `Vec` or `Tuple` with two elements scales x and y separately.
52+
An array of either scales each marker separately.
53+
Humans perceive the area of a marker as its size which grows quadratically with `markersize`,
54+
so multiplying `markersize` by 2 results in a marker that is 4 times as large, visually.
55+
"""
56+
markersize = @inherit markersize
57+
"Sets the color of the outline around a marker."
58+
strokecolor = @inherit markerstrokecolor
59+
"Sets the width of the outline around a marker."
60+
strokewidth = @inherit markerstrokewidth
61+
"Sets the color of the glow effect around the marker."
62+
glowcolor = (:black, 0.0)
63+
"Sets the size of a glow effect around the marker."
64+
glowwidth = 0.0
65+
66+
"Sets the rotation of the marker. A `Billboard` rotation is always around the depth axis."
67+
rotation = Billboard()
68+
"The offset of the marker from the given position in `markerspace` units. An offset of 0 corresponds to a centered marker."
69+
marker_offset = Vec3f(0)
70+
"Controls whether the model matrix (without translation) applies to the marker itself, rather than just the positions. (If this is true, `scale!` and `rotate!` will affect the marker."
71+
transform_marker = false
72+
"Sets the font used for character markers. Can be a `String` specifying the (partial) name of a font or the file path of a font file"
73+
font = @inherit markerfont
74+
"Optional distancefield used for e.g. font and bezier path rendering. Will get set automatically."
75+
distancefield = nothing
76+
"""
77+
Sets the font to be used for character markers
78+
"""
79+
font = "default"
80+
"Sets the space in which `markersize` is given. See `Makie.spaces()` for possible inputs"
81+
markerspace = :pixel
82+
"""
83+
Sets which attributes to cycle when creating multiple plots. The values to
84+
cycle through are defined by the parent Theme. Multiple cycled attributes can
85+
be set by passing a vector. Elements can
86+
- directly refer to a cycled attribute, e.g. `:color`
87+
- map a cycled attribute to a palette attribute, e.g. `:linecolor => :color`
88+
- map multiple cycled attributes to a palette attribute, e.g. `[:linecolor, :markercolor] => :color`
89+
"""
90+
cycle = [:color]
91+
"Enables depth-sorting of markers which can improve border artifacts. Currently supported in GLMakie only."
92+
depthsorting = false
93+
mixin_generic_plot_attributes()...
94+
mixin_colormap_attributes()...
95+
fxaa = false
96+
end
97+
end
98+
199
"""
2100
smithplot(z; kwargs...)
3101
@@ -24,16 +122,16 @@ fig
24122
```
25123
26124
"""
27-
@recipe SmithPlot (z, ) begin
125+
@recipe SmithPlot (z,) begin
28126
"Specifies whether it is a normalized impedance or a reflection coefficient."
29-
reflection=false
127+
reflection = false
30128
" Array of frequencies associated with each represented value. Mainly used by `DataInspector`"
31129
freq = Float64[]
32-
Makie.documented_attributes(Lines)...
130+
smithplot_attributes()...
33131
end
34132

35-
argument_names(::Type{<: SmithPlot}, N) = (:z, )
36-
Makie.preferred_axis_type(plot::SmithPlot) = SmithAxis
133+
argument_names(::Type{<:SmithPlot}, N) = (:z,)
134+
Makie.preferred_axis_type(plot::SmithPlot) = SmithAxis
37135

38136
"""
39137
smithscatter(z; kwargs...)
@@ -59,16 +157,16 @@ fig
59157
```
60158
61159
"""
62-
@recipe SmithScatter (z, ) begin
160+
@recipe SmithScatter (z,) begin
63161
"Specifies whether it is a normalized impedance or a reflection coefficient."
64-
reflection=false
162+
reflection = false
65163
" Array of frequencies associated with each represented value. Mainly used by `DataInspector`"
66164
freq = Float64[]
67-
Makie.documented_attributes(Scatter)...
165+
smithscatter_attributes()...
68166
end
69167

70-
argument_names(::Type{<: SmithScatter}, N) = (:z, )
71-
Makie.preferred_axis_type(plot::SmithScatter) = SmithAxis
168+
argument_names(::Type{<:SmithScatter}, N) = (:z,)
169+
Makie.preferred_axis_type(plot::SmithScatter) = SmithAxis
72170

73171

74172
function Makie.show_data(inspector::DataInspector, plot::SmithPlot, idx, ::Lines)
@@ -93,10 +191,10 @@ function Makie.show_data(inspector::DataInspector, plot::SmithPlot, idx, ::Lines
93191
if !isempty(a.freq[])
94192
f = a.freq[][idx]
95193
ftext = f < 1.0e3 ? @sprintf("%.3f Hz", f) :
96-
f < 1.0e6 ? @sprintf("%.3f kHz", f/1.0e3) :
97-
f < 1.0e9 ? @sprintf("%.3f MHz", f/1.0e6) :
98-
f < 1.0e12 ? @sprintf("%.3f GHz", f/1.0e9) :
99-
@sprintf("%.3f THz", f/1.0e12)
194+
f < 1.0e6 ? @sprintf("%.3f kHz", f / 1.0e3) :
195+
f < 1.0e9 ? @sprintf("%.3f MHz", f / 1.0e6) :
196+
f < 1.0e12 ? @sprintf("%.3f GHz", f / 1.0e9) :
197+
@sprintf("%.3f THz", f / 1.0e12)
100198
text *= "\n f = " * ftext
101199
end
102200
Makie.update_tooltip_alignment!(inspector, proj_pos; text)
@@ -126,10 +224,10 @@ function Makie.show_data(inspector::DataInspector, plot::SmithScatter, idx, ::Sc
126224
if !isempty(a.freq[])
127225
f = a.freq[][idx]
128226
ftext = f < 1.0e3 ? @sprintf("%.3f Hz", f) :
129-
f < 1.0e6 ? @sprintf("%.3f kHz", f/1.0e3) :
130-
f < 1.0e9 ? @sprintf("%.3f MHz", f/1.0e6) :
131-
f < 1.0e12 ? @sprintf("%.3f GHz", f/1.0e9) :
132-
@sprintf("%.3f THz", f/1.0e12)
227+
f < 1.0e6 ? @sprintf("%.3f kHz", f / 1.0e3) :
228+
f < 1.0e9 ? @sprintf("%.3f MHz", f / 1.0e6) :
229+
f < 1.0e12 ? @sprintf("%.3f GHz", f / 1.0e9) :
230+
@sprintf("%.3f THz", f / 1.0e12)
133231
text *= "\n f = " * ftext
134232
end
135233

0 commit comments

Comments
 (0)