Skip to content

Plots integration #13

@PhilipVinc

Description

@PhilipVinc

With some painful reverse engineering, I realised that we can use Plots.jl to integrate with StripplePlotly with the following:

using Mesurements
using Plots

function to_plotly_base(pl)
  pl = Plots.plotlybase_syncplot(pl)
  delete!(pl.layout.fields, :height)
  delete!(pl.layout.fields, :width)
  pl.layout.fields[:margin] = Dict(:l=>50, :b=>50, :r=>50, :t=>60)
  return pl
end

# generate data with errors
y = Measurements.measurement(rand(10), rand(10)*0.1)

# use recipes from plots.jl
plt = plot(1:10, y)

# this object now is a PlotlyBase.Plot and can be used with Stripple
plt = to_plotly_base(plt)

# update the model
model.plot_data[] = plt.data
model.plot_layout[] = plt.layout

It would be nice if this could be done automatically.

(The margins are the default from PlotlyBase, because the default from Plots jl get cropped when using them with stripple)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions