Genie Discord forum

Author AvatarSven
9/11/2023, 11:07:07 AM

Hello I am trying to set the bubble size for PlotData:

plotdata(data, :A, :B, groupfeature=:C, plot = "Bubble", marker = PlotDataMarker(size=data.B))

But they al l come back with the same size, where data.B is a vector of different Ints. Anything I try, all markers remain one and the same size for all. Anyone can help? Thanks.

Author AvatarPere
9/11/2023, 3:57:13 PM

It is better that you use Plotly objects from PlotlyBase.jl and Plotly.jl for plots. Then you can easily change the properties via attributes

Author AvatarSven
9/13/2023, 10:00:02 AM

Hello Pere, thanks for replying, I am still struggling somewhat with plotting things within the Genie Framework (I am working with the Genie Builder), although I also got some stuff working now. Concerning your reply, setting plot objects via PlotlyBase.jl is clear to me, so I follow conventions from here:

@out some_plot = Plot() 

@onchange xyz begin
  some_plot = Plot(trace, layout)

the trace and the layout though , are recommended to be set from PlotlyJS.jl at least everything in PlotlyBase.jl points to it. In your reply you suggest Plotly.jl, which also points to PlotlyJS.jl can you verify what you see as best practice please, its not entirely clear to me.

Further, the hardly documented StipplePlotly package, with PlotData, and plotdata should not be used anymore, or at least not for the no-code editor?

My general idea of setting things up would be:

module App
# set up Genie development environment
using GenieFramework
using DataFrames
using PlotlyBase
using RDatasets: dataset

df_accidents = dataset("Ecdat", "Airq") |> DataFrame
features = [:AirQ, :Rain, :Vala, :Coas]

# add reactive code to make the UI interactive
@app begin

    @out features
    @in plot_feature = :AirQ    

    @out box_plot = Plot()
    @out box_plot_layout = PlotlyBase.Layout(title="Box Plot")

    @onchange isready, plot_feature begin
        box_trace = box(; y = df_accidents[!, plot_feature])
        box_plot = Plot(box_trace)
        box_plot_layout = PlotlyBase.Layout(; title="Box Plot of $(plot_feature)")

@page("/", "app.jl.html")

So this should run without errors, considering you link it to a Select and Chart Object in the Genie Builder.

Author AvatarSven
9/14/2023, 10:21:56 AM

To answer my own question, to control the size of the individual markers, a reasonable approach would be:

Plot(scatter(data, x=:A, y=:B, color=:A,
                                                sizeref=maximum(data.B) / (20^2), 
                                                sizemode="area"), mode="markers" 

Here datais a dataframe, A is some x-axis attribute, B is a count of these attributes in my case, the individual size of the markers requires a reference point, which here is the maximum of the count sizeref=maximum(data.B). The Markers are all the same color in this solution.