[Makie] Get data from figure

Given a Figure, is it possible to get the Arrays with the data? I want to do tests on automatically setting legal limits for log scale plots by automatically adjusting limits to hide the offending points, and printing a warning.

The axes are in figure.content, from there you can do ax.scene.plots to get the plots, and check their inputs. Is that what you mean?

1 Like

Yes! Thanks

sorry for being dumb about this, but i need a further hint. ax.scene.plots[1] has the following fields. which one contains the inputs? i can’t find it:

alpha              calculated_colors  color              colormap           colorrange
colorscale         cycle              depth_shift        distancefield      fxaa
glowcolor          glowwidth          highclip           inspectable        lowclip
marker             marker_offset      markersize         markerspace        model
nan_color          overdraw           rotations          space              ssao
strokecolor        strokewidth        transform_marker   transformation     transparency
uv_offset_width    visible

there is an .args field and a .converted field but those are kind of internal

julia> fig, ax, plt = plot(0:10, sin.(0:10));

julia> fig.content[1].scene.plots[1].input_args
(Observable(0:10), Observable([0.0, 0.8414709848078965, 0.9092974268256817, 0.1411200080598672, -0.7568024953079282, -0.9589242746631385, -0.27941549819892586, 0.6569865987187891, 0.9893582466233818, 0.4121184852417566, -0.5440211108893698]))

Or, alternatively:

julia> fig.content[1].scene.plots[1][1][]
11-element Vector{Point{2, Float32}}:
 [0.0, 0.0]
 [1.0, 0.84147096]
 [2.0, 0.9092974]
 [3.0, 0.14112]
 [4.0, -0.7568025]
 [5.0, -0.9589243]
 [6.0, -0.2794155]
 [7.0, 0.6569866]
 [8.0, 0.98935825]
 [9.0, 0.4121185]
 [10.0, -0.5440211]

As you can see by the gymnastics required to extract the values, this is mucking about in the internals. Perhaps it would be nice to have a function that takes an axis, and returns all data currently in it?

3 Likes