diff --git a/src/Plots.jl b/src/Plots.jl index 35b16001..f09115e5 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -1,5 +1,7 @@ module Plots +_current_plots_version = v"0.20.1" + using Reexport import StaticArrays diff --git a/src/backends.jl b/src/backends.jl index 9a5a7e1c..00ac483a 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -330,6 +330,126 @@ function add_backend_string(pkg::AbstractBackend) """ end +# ------------------------------------------------------------------------------ +# gr + +const _gr_attr = merge_with_base_supported([ + :annotations, + :background_color_legend, :background_color_inside, :background_color_outside, + :foreground_color_legend, :foreground_color_grid, :foreground_color_axis, + :foreground_color_text, :foreground_color_border, + :label, + :seriescolor, :seriesalpha, + :linecolor, :linestyle, :linewidth, :linealpha, + :markershape, :markercolor, :markersize, :markeralpha, + :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, + :fillrange, :fillcolor, :fillalpha, + :bins, + :layout, + :title, :window_title, + :guide, :lims, :ticks, :scale, :flip, + :match_dimensions, + :titlefontfamily, :titlefontsize, :titlefonthalign, :titlefontvalign, + :titlefontrotation, :titlefontcolor, + :legendfontfamily, :legendfontsize, :legendfonthalign, :legendfontvalign, + :legendfontrotation, :legendfontcolor, + :tickfontfamily, :tickfontsize, :tickfonthalign, :tickfontvalign, + :tickfontrotation, :tickfontcolor, + :guidefontfamily, :guidefontsize, :guidefonthalign, :guidefontvalign, + :guidefontrotation, :guidefontcolor, + :grid, :gridalpha, :gridstyle, :gridlinewidth, + :legend, :legendtitle, :colorbar, :colorbar_title, + :fill_z, :line_z, :marker_z, :levels, + :ribbon, :quiver, + :orientation, + :overwrite_figure, + :polar, + :aspect_ratio, + :normalize, :weights, + :inset_subplots, + :bar_width, + :arrow, + :framestyle, + :tick_direction, + :camera, + :contour_labels, +]) +const _gr_seriestype = [ + :path, :scatter, :straightline, + :heatmap, :pie, :image, + :contour, :path3d, :scatter3d, :surface, :wireframe, + :shape +] +const _gr_style = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot] +const _gr_marker = _allMarkers +const _gr_scale = [:identity, :log10] +is_marker_supported(::GRBackend, shape::Shape) = true + +function add_backend_string(::GRBackend) + """ + Pkg.add("GR") + Pkg.build("GR") + """ +end + +# ------------------------------------------------------------------------------ +# plotly + +const _plotly_attr = merge_with_base_supported([ + :annotations, + :background_color_legend, :background_color_inside, :background_color_outside, + :foreground_color_legend, :foreground_color_guide, + :foreground_color_grid, :foreground_color_axis, + :foreground_color_text, :foreground_color_border, + :foreground_color_title, + :label, + :seriescolor, :seriesalpha, + :linecolor, :linestyle, :linewidth, :linealpha, + :markershape, :markercolor, :markersize, :markeralpha, + :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, :markerstrokestyle, + :fillrange, :fillcolor, :fillalpha, + :bins, + :title, :title_location, + :titlefontfamily, :titlefontsize, :titlefonthalign, :titlefontvalign, + :titlefontcolor, + :legendfontfamily, :legendfontsize, :legendfontcolor, + :tickfontfamily, :tickfontsize, :tickfontcolor, + :guidefontfamily, :guidefontsize, :guidefontcolor, + :window_title, + :guide, :lims, :ticks, :scale, :flip, :rotation, + :tickfont, :guidefont, :legendfont, + :grid, :gridalpha, :gridlinewidth, + :legend, :colorbar, :colorbar_title, + :marker_z, :fill_z, :line_z, :levels, + :ribbon, :quiver, + :orientation, + # :overwrite_figure, + :polar, + :normalize, :weights, + # :contours, + :aspect_ratio, + :hover, + :inset_subplots, + :bar_width, + :clims, + :framestyle, + :tick_direction, + :camera, + :contour_labels, + ]) + +const _plotly_seriestype = [ + :path, :scatter, :pie, :heatmap, + :contour, :surface, :wireframe, :path3d, :scatter3d, :shape, :scattergl, + :straightline +] +const _plotly_style = [:auto, :solid, :dash, :dot, :dashdot] +const _plotly_marker = [ + :none, :auto, :circle, :rect, :diamond, :utriangle, :dtriangle, + :cross, :xcross, :pentagon, :hexagon, :octagon, :vline, :hline +] +const _plotly_scale = [:identity, :log10] + # ------------------------------------------------------------------------------ # glvisualize @@ -347,18 +467,56 @@ function _initialize_backend(::GLVisualizeBackend; kw...) end end -# ------------------------------------------------------------------------------ -# hdf5 - -function _initialize_backend(::HDF5Backend) - @eval Main begin - import HDF5 - export HDF5 - end -end +const _glvisualize_attr = merge_with_base_supported([ + :annotations, + :background_color_legend, :background_color_inside, :background_color_outside, + :foreground_color_grid, :foreground_color_legend, :foreground_color_title, + :foreground_color_axis, :foreground_color_border, :foreground_color_guide, :foreground_color_text, + :label, + :linecolor, :linestyle, :linewidth, :linealpha, + :markershape, :markercolor, :markersize, :markeralpha, + :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, + :fillrange, :fillcolor, :fillalpha, + :bins, :bar_width, :bar_edges, :bar_position, + :title, :title_location, + :window_title, + :guide, :lims, :ticks, :scale, :flip, :rotation, + :titlefontsize, :titlefontcolor, + :legendfontsize, :legendfontcolor, + :tickfontsize, + :guidefontsize, :guidefontcolor, + :grid, :gridalpha, :gridstyle, :gridlinewidth, + :legend, :colorbar, + :marker_z, + :line_z, + :levels, + :ribbon, :quiver, :arrow, + :orientation, + :overwrite_figure, + #:polar, + :normalize, :weights, + :contours, :aspect_ratio, + :match_dimensions, + :clims, + :inset_subplots, + :dpi, + :hover, + :framestyle, + :tick_direction, +]) +const _glvisualize_seriestype = [ + :path, :shape, :straightline, + :scatter, :hexbin, + :bar, :boxplot, + :heatmap, :image, :volume, + :contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe +] +const _glvisualize_style = [:auto, :solid, :dash, :dot, :dashdot] +const _glvisualize_marker = _allMarkers +const _glvisualize_scale = [:identity, :ln, :log2, :log10] # ------------------------------------------------------------------------------ -# PGFPLOTS +# pgfplots function add_backend_string(::PGFPlotsBackend) """ @@ -368,19 +526,72 @@ function add_backend_string(::PGFPlotsBackend) """ end +const _pgfplots_attr = merge_with_base_supported([ + :annotations, + :background_color_legend, + :background_color_inside, + # :background_color_outside, + # :foreground_color_legend, + :foreground_color_grid, :foreground_color_axis, + :foreground_color_text, :foreground_color_border, + :label, + :seriescolor, :seriesalpha, + :linecolor, :linestyle, :linewidth, :linealpha, + :markershape, :markercolor, :markersize, :markeralpha, + :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, :markerstrokestyle, + :fillrange, :fillcolor, :fillalpha, + :bins, + # :bar_width, :bar_edges, + :title, + # :window_title, + :guide, :guide_position, :lims, :ticks, :scale, :flip, :rotation, + :tickfont, :guidefont, :legendfont, + :grid, :legend, + :colorbar, :colorbar_title, + :fill_z, :line_z, :marker_z, :levels, + # :ribbon, :quiver, :arrow, + # :orientation, + # :overwrite_figure, + :polar, + # :normalize, :weights, :contours, + :aspect_ratio, + # :match_dimensions, + :tick_direction, + :framestyle, + :camera, + :contour_labels, +]) +const _pgfplots_seriestype = [:path, :path3d, :scatter, :steppre, :stepmid, :steppost, :histogram2d, :ysticks, :xsticks, :contour, :shape, :straightline,] +const _pgfplots_style = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot] +const _pgfplots_marker = [:none, :auto, :circle, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :pentagon, :hline] #vcat(_allMarkers, Shape) +const _pgfplots_scale = [:identity, :ln, :log2, :log10] + # ------------------------------------------------------------------------------ # plotlyjs +function _initialize_backend(pkg::PlotlyJSBackend) + sym = backend_package_name(pkg) + @eval Main begin + import PlotlyJS, ORCA + export PlotlyJS + end +end + function add_backend_string(::PlotlyJSBackend) """ using Pkg - Pkg.add("PlotlyJS") - Pkg.add("Rsvg") + Pkg.add(["PlotlyJS", "Blink", "ORCA"]) import Blink Blink.AtomShell.install() """ end +const _plotlyjs_attr = _plotly_attr +const _plotlyjs_seriestype = _plotly_seriestype +const _plotlyjs_style = _plotly_style +const _plotlyjs_marker = _plotly_marker +const _plotlyjs_scale = _plotly_scale + # ------------------------------------------------------------------------------ # pyplot @@ -409,8 +620,59 @@ function add_backend_string(::PyPlotBackend) """ end +const _pyplot_attr = merge_with_base_supported([ + :annotations, + :background_color_legend, :background_color_inside, :background_color_outside, + :foreground_color_grid, :foreground_color_legend, :foreground_color_title, + :foreground_color_axis, :foreground_color_border, :foreground_color_guide, :foreground_color_text, + :label, + :linecolor, :linestyle, :linewidth, :linealpha, + :markershape, :markercolor, :markersize, :markeralpha, + :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, + :fillrange, :fillcolor, :fillalpha, + :bins, :bar_width, :bar_edges, :bar_position, + :title, :title_location, :titlefont, + :window_title, + :guide, :guide_position, :lims, :ticks, :scale, :flip, :rotation, + :titlefontfamily, :titlefontsize, :titlefontcolor, + :legendfontfamily, :legendfontsize, :legendfontcolor, + :tickfontfamily, :tickfontsize, :tickfontcolor, + :guidefontfamily, :guidefontsize, :guidefontcolor, + :grid, :gridalpha, :gridstyle, :gridlinewidth, + :legend, :legendtitle, :colorbar, + :marker_z, :line_z, :fill_z, + :levels, + :ribbon, :quiver, :arrow, + :orientation, + :overwrite_figure, + :polar, + :normalize, :weights, + :contours, :aspect_ratio, + :match_dimensions, + :clims, + :inset_subplots, + :dpi, + :colorbar_title, + :stride, + :framestyle, + :tick_direction, + :camera, + :contour_labels, + ]) +const _pyplot_seriestype = [ + :path, :steppre, :steppost, :shape, :straightline, + :scatter, :hexbin, #:histogram2d, :histogram, + # :bar, + :heatmap, :pie, :image, + :contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe + ] +const _pyplot_style = [:auto, :solid, :dash, :dot, :dashdot] +const _pyplot_marker = vcat(_allMarkers, :pixel) +const _pyplot_scale = [:identity, :ln, :log2, :log10] + # ------------------------------------------------------------------------------ # unicodeplots + function add_backend_string(::UnicodePlotsBackend) """ using Pkg @@ -418,3 +680,126 @@ function add_backend_string(::UnicodePlotsBackend) Pkg.build("UnicodePlots") """ end + +const _unicodeplots_attr = merge_with_base_supported([ + :label, + :legend, + :seriescolor, + :seriesalpha, + :linestyle, + :markershape, + :bins, + :title, + :guide, :lims, + ]) +const _unicodeplots_seriestype = [ + :path, :scatter, :straightline, + # :bar, + :shape, + :histogram2d, + :spy +] +const _unicodeplots_style = [:auto, :solid] +const _unicodeplots_marker = [:none, :auto, :circle] +const _unicodeplots_scale = [:identity] + +# ------------------------------------------------------------------------------ +# hdf5 + +const _hdf5_attr = merge_with_base_supported([ + :annotations, + :background_color_legend, :background_color_inside, :background_color_outside, + :foreground_color_grid, :foreground_color_legend, :foreground_color_title, + :foreground_color_axis, :foreground_color_border, :foreground_color_guide, :foreground_color_text, + :label, + :linecolor, :linestyle, :linewidth, :linealpha, + :markershape, :markercolor, :markersize, :markeralpha, + :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, + :fillrange, :fillcolor, :fillalpha, + :bins, :bar_width, :bar_edges, :bar_position, + :title, :title_location, :titlefont, + :window_title, + :guide, :lims, :ticks, :scale, :flip, :rotation, + :tickfont, :guidefont, :legendfont, + :grid, :legend, :colorbar, + :marker_z, :line_z, :fill_z, + :levels, + :ribbon, :quiver, :arrow, + :orientation, + :overwrite_figure, + :polar, + :normalize, :weights, + :contours, :aspect_ratio, + :match_dimensions, + :clims, + :inset_subplots, + :dpi, + :colorbar_title, + ]) +const _hdf5_seriestype = [ + :path, :steppre, :steppost, :shape, :straightline, + :scatter, :hexbin, #:histogram2d, :histogram, + # :bar, + :heatmap, :pie, :image, + :contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe + ] +const _hdf5_style = [:auto, :solid, :dash, :dot, :dashdot] +const _hdf5_marker = vcat(_allMarkers, :pixel) +const _hdf5_scale = [:identity, :ln, :log2, :log10] + +# ------------------------------------------------------------------------------ +# inspectdr + +const _inspectdr_attr = merge_with_base_supported([ + :annotations, + :background_color_legend, :background_color_inside, :background_color_outside, + # :foreground_color_grid, + :foreground_color_legend, :foreground_color_title, + :foreground_color_axis, :foreground_color_border, :foreground_color_guide, :foreground_color_text, + :label, + :seriescolor, :seriesalpha, + :linecolor, :linestyle, :linewidth, :linealpha, + :markershape, :markercolor, :markersize, :markeralpha, + :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, + :markerstrokestyle, #Causes warning not to have it... what is this? + :fillcolor, :fillalpha, #:fillrange, +# :bins, :bar_width, :bar_edges, :bar_position, + :title, :title_location, + :window_title, + :guide, :lims, :scale, #:ticks, :flip, :rotation, + :titlefontfamily, :titlefontsize, :titlefontcolor, + :legendfontfamily, :legendfontsize, :legendfontcolor, + :tickfontfamily, :tickfontsize, :tickfontcolor, + :guidefontfamily, :guidefontsize, :guidefontcolor, + :grid, :legend, #:colorbar, +# :marker_z, +# :line_z, +# :levels, + # :ribbon, :quiver, :arrow, +# :orientation, + :overwrite_figure, + :polar, +# :normalize, :weights, +# :contours, :aspect_ratio, + :match_dimensions, +# :clims, +# :inset_subplots, + :dpi, +# :colorbar_title, + ]) +const _inspectdr_style = [:auto, :solid, :dash, :dot, :dashdot] +const _inspectdr_seriestype = [ + :path, :scatter, :shape, :straightline, #, :steppre, :steppost + ] +#see: _allMarkers, _shape_keys +const _inspectdr_marker = Symbol[ + :none, :auto, + :circle, :rect, :diamond, + :cross, :xcross, + :utriangle, :dtriangle, :rtriangle, :ltriangle, + :pentagon, :hexagon, :heptagon, :octagon, + :star4, :star5, :star6, :star7, :star8, + :vline, :hline, :+, :x, +] + +const _inspectdr_scale = [:identity, :ln, :log2, :log10] diff --git a/src/backends/glvisualize.jl b/src/backends/glvisualize.jl index 72288380..72f7c74e 100644 --- a/src/backends/glvisualize.jl +++ b/src/backends/glvisualize.jl @@ -9,53 +9,7 @@ TODO * fix units in all visuals (e.g dotted lines, marker scale, surfaces) =# -const _glvisualize_attr = merge_with_base_supported([ - :annotations, - :background_color_legend, :background_color_inside, :background_color_outside, - :foreground_color_grid, :foreground_color_legend, :foreground_color_title, - :foreground_color_axis, :foreground_color_border, :foreground_color_guide, :foreground_color_text, - :label, - :linecolor, :linestyle, :linewidth, :linealpha, - :markershape, :markercolor, :markersize, :markeralpha, - :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, - :fillrange, :fillcolor, :fillalpha, - :bins, :bar_width, :bar_edges, :bar_position, - :title, :title_location, - :window_title, - :guide, :lims, :ticks, :scale, :flip, :rotation, - :titlefontsize, :titlefontcolor, - :legendfontsize, :legendfontcolor, - :tickfontsize, - :guidefontsize, :guidefontcolor, - :grid, :gridalpha, :gridstyle, :gridlinewidth, - :legend, :colorbar, - :marker_z, - :line_z, - :levels, - :ribbon, :quiver, :arrow, - :orientation, - :overwrite_figure, - #:polar, - :normalize, :weights, - :contours, :aspect_ratio, - :match_dimensions, - :clims, - :inset_subplots, - :dpi, - :hover, - :framestyle, - :tick_direction, -]) -const _glvisualize_seriestype = [ - :path, :shape, :straightline, - :scatter, :hexbin, - :bar, :boxplot, - :heatmap, :image, :volume, - :contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe -] -const _glvisualize_style = [:auto, :solid, :dash, :dot, :dashdot] -const _glvisualize_marker = _allMarkers -const _glvisualize_scale = [:identity, :ln, :log2, :log10] + slice_arg(img::Matrix{C}, idx::Int) where {C<:Colorant} = img is_marker_supported(::GLVisualizeBackend, shape::GLVisualize.AllPrimitives) = true diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 267875f9..67996895 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -3,65 +3,6 @@ # significant contributions by @jheinen -const _gr_attr = merge_with_base_supported([ - :annotations, - :background_color_legend, :background_color_inside, :background_color_outside, - :foreground_color_legend, :foreground_color_grid, :foreground_color_axis, - :foreground_color_text, :foreground_color_border, - :label, - :seriescolor, :seriesalpha, - :linecolor, :linestyle, :linewidth, :linealpha, - :markershape, :markercolor, :markersize, :markeralpha, - :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, - :fillrange, :fillcolor, :fillalpha, - :bins, - :layout, - :title, :window_title, - :guide, :guide_position, :lims, :ticks, :scale, :flip, - :match_dimensions, - :titlefontfamily, :titlefontsize, :titlefonthalign, :titlefontvalign, - :titlefontrotation, :titlefontcolor, - :legendfontfamily, :legendfontsize, :legendfonthalign, :legendfontvalign, - :legendfontrotation, :legendfontcolor, - :tickfontfamily, :tickfontsize, :tickfonthalign, :tickfontvalign, - :tickfontrotation, :tickfontcolor, - :guidefontfamily, :guidefontsize, :guidefonthalign, :guidefontvalign, - :guidefontrotation, :guidefontcolor, - :grid, :gridalpha, :gridstyle, :gridlinewidth, - :legend, :legendtitle, :colorbar, :colorbar_title, - :fill_z, :line_z, :marker_z, :levels, - :ribbon, :quiver, - :orientation, - :overwrite_figure, - :polar, - :aspect_ratio, - :normalize, :weights, - :inset_subplots, - :bar_width, - :arrow, - :framestyle, - :tick_direction, - :camera, - :contour_labels, -]) -const _gr_seriestype = [ - :path, :scatter, :straightline, - :heatmap, :pie, :image, - :contour, :path3d, :scatter3d, :surface, :wireframe, - :shape -] -const _gr_style = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot] -const _gr_marker = _allMarkers -const _gr_scale = [:identity, :log10] -is_marker_supported(::GRBackend, shape::Shape) = true - -function add_backend_string(::GRBackend) - """ - Pkg.add("GR") - Pkg.build("GR") - """ -end - import GR export GR diff --git a/src/backends/hdf5.jl b/src/backends/hdf5.jl index 28dd767d..95b83874 100644 --- a/src/backends/hdf5.jl +++ b/src/backends/hdf5.jl @@ -62,47 +62,6 @@ const HDF5PLOT_SIMPLESUBSTRUCT = Union{Font, BoundingBox, #== ===============================================================================# - -const _hdf5_attr = merge_with_base_supported([ - :annotations, - :background_color_legend, :background_color_inside, :background_color_outside, - :foreground_color_grid, :foreground_color_legend, :foreground_color_title, - :foreground_color_axis, :foreground_color_border, :foreground_color_guide, :foreground_color_text, - :label, - :linecolor, :linestyle, :linewidth, :linealpha, - :markershape, :markercolor, :markersize, :markeralpha, - :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, - :fillrange, :fillcolor, :fillalpha, - :bins, :bar_width, :bar_edges, :bar_position, - :title, :title_location, :titlefont, - :window_title, - :guide, :lims, :ticks, :scale, :flip, :rotation, - :tickfont, :guidefont, :legendfont, - :grid, :legend, :colorbar, - :marker_z, :line_z, :fill_z, - :levels, - :ribbon, :quiver, :arrow, - :orientation, - :overwrite_figure, - :polar, - :normalize, :weights, - :contours, :aspect_ratio, - :match_dimensions, - :clims, - :inset_subplots, - :dpi, - :colorbar_title, - ]) -const _hdf5_seriestype = [ - :path, :steppre, :steppost, :shape, :straightline, - :scatter, :hexbin, #:histogram2d, :histogram, - # :bar, - :heatmap, :pie, :image, - :contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe - ] -const _hdf5_style = [:auto, :solid, :dash, :dot, :dashdot] -const _hdf5_marker = vcat(_allMarkers, :pixel) -const _hdf5_scale = [:identity, :ln, :log2, :log10] is_marker_supported(::HDF5Backend, shape::Shape) = true if length(HDF5PLOT_MAP_TELEM2STR) < 1 diff --git a/src/backends/inspectdr.jl b/src/backends/inspectdr.jl index 56fd7f32..bbc268a3 100644 --- a/src/backends/inspectdr.jl +++ b/src/backends/inspectdr.jl @@ -14,61 +14,6 @@ Add in functionality to Plots.jl: =# # --------------------------------------------------------------------------- -#TODO: remove features -const _inspectdr_attr = merge_with_base_supported([ - :annotations, - :background_color_legend, :background_color_inside, :background_color_outside, - # :foreground_color_grid, - :foreground_color_legend, :foreground_color_title, - :foreground_color_axis, :foreground_color_border, :foreground_color_guide, :foreground_color_text, - :label, - :seriescolor, :seriesalpha, - :linecolor, :linestyle, :linewidth, :linealpha, - :markershape, :markercolor, :markersize, :markeralpha, - :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, - :markerstrokestyle, #Causes warning not to have it... what is this? - :fillcolor, :fillalpha, #:fillrange, -# :bins, :bar_width, :bar_edges, :bar_position, - :title, :title_location, - :window_title, - :guide, :lims, :scale, #:ticks, :flip, :rotation, - :titlefontfamily, :titlefontsize, :titlefontcolor, - :legendfontfamily, :legendfontsize, :legendfontcolor, - :tickfontfamily, :tickfontsize, :tickfontcolor, - :guidefontfamily, :guidefontsize, :guidefontcolor, - :grid, #:gridalpha, :gridstyle, :gridlinewidth, #alhpa & linewidth are per plot - not per subplot - :legend, #:legendtitle, :colorbar, -# :marker_z, -# :line_z, -# :levels, - # :ribbon, :quiver, :arrow, -# :orientation, - :overwrite_figure, - :polar, -# :normalize, :weights, -# :contours, :aspect_ratio, - :match_dimensions, -# :clims, -# :inset_subplots, - :dpi, -# :colorbar_title, - ]) -const _inspectdr_style = [:auto, :solid, :dash, :dot, :dashdot] -const _inspectdr_seriestype = [ - :path, :scatter, :shape, :straightline, #, :steppre, :steppost - ] -#see: _allMarkers, _shape_keys -const _inspectdr_marker = Symbol[ - :none, :auto, - :circle, :rect, :diamond, - :cross, :xcross, - :utriangle, :dtriangle, :rtriangle, :ltriangle, - :pentagon, :hexagon, :heptagon, :octagon, - :star4, :star5, :star6, :star7, :star8, - :vline, :hline, :+, :x, -] - -const _inspectdr_scale = [:identity, :ln, :log2, :log10] is_marker_supported(::InspectDRBackend, shape::Shape) = true diff --git a/src/backends/pgfplots.jl b/src/backends/pgfplots.jl index 26865bb9..9b351175 100644 --- a/src/backends/pgfplots.jl +++ b/src/backends/pgfplots.jl @@ -2,47 +2,6 @@ # significant contributions by: @pkofod -const _pgfplots_attr = merge_with_base_supported([ - :annotations, - :background_color_legend, - :background_color_inside, - # :background_color_outside, - # :foreground_color_legend, - :foreground_color_grid, :foreground_color_axis, - :foreground_color_text, :foreground_color_border, - :label, - :seriescolor, :seriesalpha, - :linecolor, :linestyle, :linewidth, :linealpha, - :markershape, :markercolor, :markersize, :markeralpha, - :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, :markerstrokestyle, - :fillrange, :fillcolor, :fillalpha, - :bins, - # :bar_width, :bar_edges, - :title, - # :window_title, - :guide, :guide_position, :lims, :ticks, :scale, :flip, :rotation, - :tickfont, :guidefont, :legendfont, - :grid, :legend, - :colorbar, :colorbar_title, - :fill_z, :line_z, :marker_z, :levels, - # :ribbon, :quiver, :arrow, - # :orientation, - # :overwrite_figure, - :polar, - # :normalize, :weights, :contours, - :aspect_ratio, - # :match_dimensions, - :tick_direction, - :framestyle, - :camera, - :contour_labels, - ]) -const _pgfplots_seriestype = [:path, :path3d, :scatter, :steppre, :stepmid, :steppost, :histogram2d, :ysticks, :xsticks, :contour, :shape, :straightline,] -const _pgfplots_style = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot] -const _pgfplots_marker = [:none, :auto, :circle, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :pentagon, :hline] #vcat(_allMarkers, Shape) -const _pgfplots_scale = [:identity, :ln, :log2, :log10] - - # -------------------------------------------------------------------------------------- const _pgfplots_linestyles = KW( diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 3e525b5b..2cba0061 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -1,60 +1,6 @@ # https://plot.ly/javascript/getting-started -const _plotly_attr = merge_with_base_supported([ - :annotations, - :background_color_legend, :background_color_inside, :background_color_outside, - :foreground_color_legend, :foreground_color_guide, - :foreground_color_grid, :foreground_color_axis, - :foreground_color_text, :foreground_color_border, - :foreground_color_title, - :label, - :seriescolor, :seriesalpha, - :linecolor, :linestyle, :linewidth, :linealpha, - :markershape, :markercolor, :markersize, :markeralpha, - :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, :markerstrokestyle, - :fillrange, :fillcolor, :fillalpha, - :bins, - :title, :title_location, - :titlefontfamily, :titlefontsize, :titlefonthalign, :titlefontvalign, - :titlefontcolor, - :legendfontfamily, :legendfontsize, :legendfontcolor, - :tickfontfamily, :tickfontsize, :tickfontcolor, - :guidefontfamily, :guidefontsize, :guidefontcolor, - :window_title, - :guide, :lims, :ticks, :scale, :flip, :rotation, - :tickfont, :guidefont, :legendfont, - :grid, :gridalpha, :gridlinewidth, - :legend, :colorbar, :colorbar_title, - :marker_z, :fill_z, :line_z, :levels, - :ribbon, :quiver, - :orientation, - # :overwrite_figure, - :polar, - :normalize, :weights, - # :contours, - :aspect_ratio, - :hover, - :inset_subplots, - :bar_width, - :clims, - :framestyle, - :tick_direction, - :camera, - :contour_labels, - ]) - -const _plotly_seriestype = [ - :path, :scatter, :pie, :heatmap, - :contour, :surface, :wireframe, :path3d, :scatter3d, :shape, :scattergl, - :straightline -] -const _plotly_style = [:auto, :solid, :dash, :dot, :dashdot] -const _plotly_marker = [ - :none, :auto, :circle, :rect, :diamond, :utriangle, :dtriangle, - :cross, :xcross, :pentagon, :hexagon, :octagon, :vline, :hline -] -const _plotly_scale = [:identity, :log10] is_subplot_supported(::PlotlyBackend) = true # is_string_supported(::PlotlyBackend) = true const _plotly_framestyles = [:box, :axes, :zerolines, :grid, :none] diff --git a/src/backends/plotlyjs.jl b/src/backends/plotlyjs.jl index 98e626c1..791016d7 100644 --- a/src/backends/plotlyjs.jl +++ b/src/backends/plotlyjs.jl @@ -1,18 +1,12 @@ # https://github.com/spencerlyon2/PlotlyJS.jl -const _plotlyjs_attr = _plotly_attr -const _plotlyjs_seriestype = _plotly_seriestype -const _plotlyjs_style = _plotly_style -const _plotlyjs_marker = _plotly_marker -const _plotlyjs_scale = _plotly_scale - # -------------------------------------------------------------------------------------- function _create_backend_figure(plt::Plot{PlotlyJSBackend}) if !isplotnull() && plt[:overwrite_figure] && isa(current().o, PlotlyJS.SyncPlot) - PlotlyJS.SyncPlot(PlotlyJS.Plot(), current().o.view) + PlotlyJS.SyncPlot(PlotlyJS.Plot(), options = current().o.options) else PlotlyJS.plot() end diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 4524e967..0a581a3f 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1,55 +1,6 @@ # https://github.com/stevengj/PyPlot.jl -const _pyplot_attr = merge_with_base_supported([ - :annotations, - :background_color_legend, :background_color_inside, :background_color_outside, - :foreground_color_grid, :foreground_color_legend, :foreground_color_title, - :foreground_color_axis, :foreground_color_border, :foreground_color_guide, :foreground_color_text, - :label, - :linecolor, :linestyle, :linewidth, :linealpha, - :markershape, :markercolor, :markersize, :markeralpha, - :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, - :fillrange, :fillcolor, :fillalpha, - :bins, :bar_width, :bar_edges, :bar_position, - :title, :title_location, :titlefont, - :window_title, - :guide, :guide_position, :lims, :ticks, :scale, :flip, :rotation, - :titlefontfamily, :titlefontsize, :titlefontcolor, - :legendfontfamily, :legendfontsize, :legendfontcolor, - :tickfontfamily, :tickfontsize, :tickfontcolor, - :guidefontfamily, :guidefontsize, :guidefontcolor, - :grid, :gridalpha, :gridstyle, :gridlinewidth, - :legend, :legendtitle, :colorbar, - :marker_z, :line_z, :fill_z, - :levels, - :ribbon, :quiver, :arrow, - :orientation, - :overwrite_figure, - :polar, - :normalize, :weights, - :contours, :aspect_ratio, - :match_dimensions, - :clims, - :inset_subplots, - :dpi, - :colorbar_title, - :stride, - :framestyle, - :tick_direction, - :camera, - :contour_labels, - ]) -const _pyplot_seriestype = [ - :path, :steppre, :steppost, :shape, :straightline, - :scatter, :hexbin, #:histogram2d, :histogram, - # :bar, - :heatmap, :pie, :image, - :contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe - ] -const _pyplot_style = [:auto, :solid, :dash, :dot, :dashdot] -const _pyplot_marker = vcat(_allMarkers, :pixel) -const _pyplot_scale = [:identity, :ln, :log2, :log10] is_marker_supported(::PyPlotBackend, shape::Shape) = true @@ -1064,7 +1015,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) ticks = sp[:framestyle] == :none ? nothing : get_ticks(axis) # don't show the 0 tick label for the origin framestyle if sp[:framestyle] == :origin && length(ticks) > 1 - ticks[2][ticks[1] .== 0] = "" + ticks[2][ticks[1] .== 0] .= "" end axis[:ticks] != :native ? py_set_ticks(ax, ticks, letter) : nothing pyaxis[:set_tick_params](direction = axis[:tick_direction] == :out ? "out" : "in") diff --git a/src/backends/unicodeplots.jl b/src/backends/unicodeplots.jl index afdd08cc..370c9a87 100644 --- a/src/backends/unicodeplots.jl +++ b/src/backends/unicodeplots.jl @@ -1,28 +1,6 @@ # https://github.com/Evizero/UnicodePlots.jl -const _unicodeplots_attr = merge_with_base_supported([ - :label, - :legend, - :seriescolor, - :seriesalpha, - :linestyle, - :markershape, - :bins, - :title, - :guide, :lims, - ]) -const _unicodeplots_seriestype = [ - :path, :scatter, :straightline, - # :bar, - :shape, - :histogram2d, - :spy -] -const _unicodeplots_style = [:auto, :solid] -const _unicodeplots_marker = [:none, :auto, :circle] -const _unicodeplots_scale = [:identity] - # don't warn on unsupported... there's just too many warnings!! warnOnUnsupported_args(::UnicodePlotsBackend, plotattributes::KW) = nothing diff --git a/src/examples.jl b/src/examples.jl index e9155d0e..7050b1e3 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -437,6 +437,15 @@ each line segment or marker in the plot. ] +# Some constants for PlotDocs and PlotReferenceImages +_animation_examples = [2, 30] +_backend_skips = Dict( + :gr => [25, 30], + :pyplot => [25, 30], + :plotlyjs => [2, 21, 25, 30, 31], + :pgfplots => [2, 5, 6, 10, 16, 20, 22, 23, 25, 28, 30], +) + # --------------------------------------------------------------------------------- # make and display one plot diff --git a/src/init.jl b/src/init.jl index 08d1dd2b..545f55ea 100644 --- a/src/init.jl +++ b/src/init.jl @@ -80,4 +80,28 @@ function __init__() ENV["MPLBACKEND"] = "Agg" end end + + + + # --------------------------------------------------------- + # A backup, if no PNG generation is defined, is to try to make a PDF and use FileIO to convert + @require FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" begin + PDFBackends = Union{PGFPlotsBackend,PlotlyJSBackend,PyPlotBackend,InspectDRBackend,GRBackend} + function _show(io::IO, ::MIME"image/png", plt::Plot{<:PDFBackends}) + fn = tempname() + + # first save a pdf file + pdf(plt, fn) + + # load that pdf into a FileIO Stream + s = FileIO.load(fn * ".pdf") + + # save a png + pngfn = fn * ".png" + FileIO.save(pngfn, s) + + # now write from the file + write(io, read(open(pngfn), String)) + end + end end diff --git a/src/output.jl b/src/output.jl index 1122ab93..df6e3b84 100644 --- a/src/output.jl +++ b/src/output.jl @@ -210,30 +210,6 @@ _show(io::IO, ::MIME{Symbol("text/plain")}, plt::Plot) = show(io, plt) closeall() = closeall(backend()) -# --------------------------------------------------------- -# A backup, if no PNG generation is defined, is to try to make a PDF and use FileIO to convert - -const PDFBackends = Union{PGFPlotsBackend,PlotlyJSBackend,PyPlotBackend,InspectDRBackend,GRBackend} -if is_installed("FileIO") - @eval import FileIO - function _show(io::IO, ::MIME"image/png", plt::Plot{<:PDFBackends}) - fn = tempname() - - # first save a pdf file - pdf(plt, fn) - - # load that pdf into a FileIO Stream - s = FileIO.load(fn * ".pdf") - - # save a png - pngfn = fn * ".png" - FileIO.save(pngfn, s) - - # now write from the file - write(io, read(open(pngfn), String)) - end -end - # function html_output_format(fmt) # if fmt == "png" # @eval function Base.show(io::IO, ::MIME"text/html", plt::Plot) diff --git a/src/utils.jl b/src/utils.jl index 0db12bc5..22d3df57 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -412,14 +412,6 @@ end isijulia() = :IJulia in nameof.(collect(values(Base.loaded_modules))) isatom() = :Atom in nameof.(collect(values(Base.loaded_modules))) -function is_installed(pkgstr::AbstractString) - try - Pkg.installed(pkgstr) === nothing ? false : true - catch - false - end -end - istuple(::Tuple) = true istuple(::Any) = false isvector(::AVec) = true diff --git a/test/add_packages.jl b/test/add_packages.jl index 260707d3..4e27bb30 100644 --- a/test/add_packages.jl +++ b/test/add_packages.jl @@ -4,7 +4,6 @@ using Pkg # ENV["PYTHON"] = "" to_add = [ - PackageSpec(url="https://github.com/JuliaPlots/PlotReferenceImages.jl.git"), # PackageSpec(url="https://github.com/JuliaStats/KernelDensity.jl.git"), PackageSpec(name="PlotUtils", rev="master"), PackageSpec(name="RecipesBase", rev="master"), @@ -17,12 +16,24 @@ to_add = [ ] if isinteractive() + Pkg.develop(PackageSpec(url="https://github.com/JuliaPlots/PlotReferenceImages.jl.git")) append!(to_add, [ PackageSpec(name="FileIO"), PackageSpec(name="ImageMagick"), PackageSpec(name="UnicodePlots"), PackageSpec(name="VisualRegressionTests"), + PackageSpec(name="Gtk"), + # PlotlyJS: + # PackageSpec(name="PlotlyJS"), + # PackageSpec(name="Blink"), + # PackageSpec(name="ORCA"), + # PyPlot: + # PackageSpec(name="PyPlot"), + # PackageSpec(name="PyCall"), + # PackageSpec(name="LaTeXStrings"), ]) +else + push!(to_add, PackageSpec(url="https://github.com/JuliaPlots/PlotReferenceImages.jl.git")) end Pkg.add(to_add) diff --git a/test/imgcomp.jl b/test/imgcomp.jl index f52e5a38..526d695e 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -29,7 +29,7 @@ default(size=(500,300)) # TODO: use julia's Condition type and the wait() and notify() functions to initialize a Window, then wait() on a condition that # is referenced in a button press callback (the button clicked callback will call notify() on that condition) -const _current_plots_version = v"0.20.3" +import Plots._current_plots_version function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = isinteractive(), sigma = [1,1], tol = 1e-2) diff --git a/test/runtests.jl b/test/runtests.jl index 543b8ea3..f98f877c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -14,16 +14,19 @@ img_tol = isinteractive() ? 1e-2 : 10e-2 @test gr() == Plots.GRBackend() @test backend() == Plots.GRBackend() - image_comparison_facts(:gr, tol=img_tol, skip = [25, 30]) + @static if Sys.islinux() + image_comparison_facts(:gr, tol=img_tol, skip = [25, 30]) + end end - -#@testset "PyPlot" begin -# @test pyplot() == Plots.PyPlotBackend() -# @test backend() == Plots.PyPlotBackend() +# @static if isinteractive() +# @testset "PyPlot" begin +# @test pyplot() == Plots.PyPlotBackend() +# @test backend() == Plots.PyPlotBackend() # -# image_comparison_facts(:pyplot, tol=img_tol) -#end +# image_comparison_facts(:pyplot, tol=img_tol, skip = [2, 25, 30, 31]) +# end +# end @testset "UnicodePlots" begin @test unicodeplots() == Plots.UnicodePlotsBackend() @@ -36,22 +39,23 @@ end # The plotlyjs testimages return a connection error on travis: # connect: connection refused (ECONNREFUSED) -# @testset "PlotlyJS" begin -# @test plotlyjs() == Plots.PlotlyJSBackend() -# @test backend() == Plots.PlotlyJSBackend() +# @static if isinteractive() +# @testset "PlotlyJS" begin +# @test plotlyjs() == Plots.PlotlyJSBackend() +# @test backend() == Plots.PlotlyJSBackend() # -# if Sys.islinux() && isinteractive() # image_comparison_facts(:plotlyjs, # skip=[ # 2, # animation (skipped for speed) +# 25, # 27, # (polar plots) takes very long / not working +# 30, # 31, # animation (skipped for speed) # ], # tol=img_tol) # end # end - # InspectDR returns that error on travis: # ERROR: LoadError: InitError: Cannot open display: # in Gtk.GLib.GError(::Gtk.##229#230) at /home/travis/.julia/v0.5/Gtk/src/GLib/gerror.jl:17