|
29 | 29 |
|
30 | 30 | function fixaxis!(attr, x, axisletter) |
31 | 31 | # Attribute keys |
32 | | - axislabel = Symbol(axisletter, :guide) # xguide, yguide, zguide |
33 | | - axislims = Symbol(axisletter, :lims) # xlims, ylims, zlims |
34 | | - axisticks = Symbol(axisletter, :ticks) # xticks, yticks, zticks |
35 | 32 | err = Symbol(axisletter, :error) # xerror, yerror, zerror |
36 | 33 | axisunit = Symbol(axisletter, :unit) # xunit, yunit, zunit |
37 | 34 | axis = Symbol(axisletter, :axis) # xaxis, yaxis, zaxis |
38 | | - u = get!(attr, axisunit, _unit(eltype(x))) # get the unit |
39 | | - # if the subplot already exists with data, use that unit instead |
| 35 | + # if the subplot already exists with data, use that unit |
40 | 36 | sp = get(attr, :subplot, 1) |
41 | | - if sp ≤ length(attr[:plot_object]) && attr[:plot_object].n > 0 |
| 37 | + if sp ≤ length(attr[:plot_object]) |
42 | 38 | spu = getaxisunit(attr[:plot_object][sp][axis]) |
43 | 39 | if !isnothing(spu) |
44 | 40 | u = spu |
| 41 | + else # Subplot exists but doesn't have a unit yet |
| 42 | + u = get!(attr, axisunit, _unit(eltype(x))) # get the unit |
45 | 43 | end |
46 | | - attr[axisunit] = u # update the unit in the attributes |
| 44 | + else # Subplot doesn't exist yet, so create it with given unit |
| 45 | + u = get!(attr, axisunit, _unit(eltype(x))) # get the unit |
47 | 46 | end |
48 | 47 | # fix the attributes: labels, lims, ticks, marker/line stuff, etc. |
49 | 48 | ustripattribute!(attr, err, u) |
|
0 commit comments