Can one set Configuration Options using PlotlyJS.jl?

This plotly.com page describes configuration options, such as editable, displayModeBar, and displaylogo that I would like to try from Julia and PlotlyJS.jl. Is there a way to send those options? I’ve tried as keywords in the plot command and they are not recognized.

EDIT: based on @PetrKryslUCSD’s code example, this plot(plotdata,layout;options=Dict(:displaylogo=>false)) seems to work for me.

I struggled with it too. Here is something that I found to work: https://github.com/PetrKryslUCSD/FinEtoolsBeamsVis.jl/blob/20c58ef9942024dd8118783bbef07ebebfa81f9f/src/FinEtoolsBeamsVis.jl#L202

1 Like

Does this still work with PlotlyJS 0.16? I get


for

julia> options = Dict(
               :showSendToCloud=>true,
                       :plotlyServerURL=>"https://chart-studio.plotly.com"
                               , :showLink=>true, :displayLogo=>false)
Dict{Symbol, Any} with 4 entries:
  :showLink        => true
  :showSendToCloud => true
  :displayLogo     => false
  :plotlyServerURL => "https://chart-studio.plotly.com"

julia> p=plot(rand(10, 4), layout, options=options)

So not as expected. Issue has been created at What happened to the options in 0.16? · Issue #390 · JuliaPlots/PlotlyJS.jl · GitHub.

Looks like there was a special data structure introduced for this purpose. This works with PlotlyJS 0.16:

julia> options = PlotConfig(plotlyServerURL="https://chart-studio.plotly.com", showLink=true)

julia> p=plot(rand(10, 4), layout, config=options)
1 Like

Hi PetrKrysl

Does this link still work? I can not access this page or any other page where all plotly options are explained, for instance, how to set the date names from english to other languages.

Sorry: which link do you mean? In case it is the May 2020 one: The package mentioned above has been redesigned. Here are the plotting utilities: https://github.com/PetrKryslUCSD/FinEtoolsFlexBeams.jl/blob/c0d2a9ca63dda8a51af886e5b21e429237d6e2a4/src/VisUtilModule.jl#L239

Hello,

My question addressed the topic " Can one set Configuration Options using PlotlyJS.jl? "

The plotly homepage for Julia has a subpage https://plotly.com/julia/configuration-options/ explaining some configurations. The at the bottom of this page mentioned link https://github.com/plotly/plotly.js/blob/master/src/plotapi/plotconfig.js#L6 does not exist

I hoped to find a section towards configs on https://plotly.com/julia/reference/.

The reason for asking was the wish to change plotly axes ticklabels for dates from english to German.

Thanks for helping!

@Dieter
Country specifific datetime cannot be set via configuration, but using custom Dates.LOCALES["german"]
If you have a DataFrame with a column date in european(german) format, then you must proceed as follows:

using PlotlyJS, DataFrames, Dates
Dates.LOCALES["german"]= Dates.DateLocale(
      ["Januar", "Februar", "März", "April", "Mai","Juni",
      "Juli", "August", "September", "Oktober", "November", "Dezember"],
      ["Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep",
       "Okt", "Nov","Dez"],
      ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"],  [""])

#your data frame with date given as a string "day-month-year":
df= DataFrame(date=["15-0$k-2021" for k in 1:9], A=rand(10:20, 9))
df[!, :date] = Date.(df.date, "dd-mm-yyyy")  #convert strings to Date
#set Date in the format you want to be displayed in your plot:
newdate= [Dates.format(d, "dd U yyyy"; locale="german") for d in df[!, :date] ]
#or newdate=[Dates.format(d, "dd u yyyy"; locale="german") for d in df[!, :date] ]
fig = plot(
    scatter(x=newdate, y=df[!,:A], color=:symbol),
    Layout(width=700,
           title="German style date", xaxis_tickangle=-45
          )
    )

2 Likes

Thanks Empet, such stand alone examples are the best way to learn Julia :slight_smile: