Hi everyone,
I am trying to adapt a piece of code from Plotly into PlotlyJS. This code allows editing the titles of individual subplots produced with facet_row
and facet_col
by changing the default format. I have tried hard, but somehow I failed to translate the code.
The MWE is as follows. With the code:
using PlotlyJS
using DataFrames
using CSV
df_tips =CSV.read("tips.csv" , delim=';' , DataFrame)
fig = plot(df_tips, x=:total_bill, y=:tip, facet_col=:sex, color=:smoker, mode="markers")
and with the tips.csv
dataset (from here ), I can generate the plot below:
I need to remove the “facet_col” name: sex=
, which appears in all subplots. In this simple example, this repetition is irrelevant, but in figures with many subplots, this particular characteristic turns out to be quite disturbing.
There is a discussion of this problem here, and on the Plotly website here there is an explanation of how it can be implemented:
import plotly.express as px
fig = px.scatter(px.data.tips(), x="total_bill", y="tip", facet_col="smoker")
fig.for_each_annotation(lambda a: a.update(text=a.text.split("=")[-1]))
fig.show()
I am missing how to adapt the third code line above to the context of PlotlyJS:
fig.for_each_annotation(lambda a: a.update(text=a.text.split("=")[-1]))
Help will be very much appreciated. Thanks.