Skip to content

Commit

Permalink
Merge branch 'master' into extrakws_warn
Browse files Browse the repository at this point in the history
  • Loading branch information
isentropic authored May 29, 2024
2 parents 428b460 + a03e19f commit 8bf9d59
Show file tree
Hide file tree
Showing 30 changed files with 187 additions and 201 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- Plots is in a 2.0 transition phase. Consider (also) targeting the v2 branch with this change -->
## Description

## Attribution
Expand Down
28 changes: 20 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: ci

on:
pull_request:
push:
branches: [master]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -22,32 +22,42 @@ jobs:
JULIA_CONDAPKG_BACKEND: "MicroMamba"
MPLBACKEND: "agg"
name: Julia ${{ matrix.version }} - ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.version == 'nightly' }}
strategy:
fail-fast: false
matrix:
version:
- '1.6' # LTS (minimal declared julia compat in `Project.toml`)
- '1.9' # latest stable
- '1' # latest stable
experimental:
- false
os: [ubuntu-latest, windows-latest, macos-latest]
arch: [x64]
include:
- os: ubuntu-latest
experimental: false
prefix: xvfb-run # julia-actions/julia-runtest/blob/master/README.md
- os: ubuntu-latest
experimental: false
prefix: xvfb-run
version: '1.7' # only test intermediate release on `ubuntu` to spare resources
- os: ubuntu-latest
experimental: false
prefix: xvfb-run
version: '1.8' # only test intermediate release on `ubuntu` to spare resources
- os: ubuntu-latest
experimental: false
prefix: xvfb-run
version: '1.9' # only test intermediate release on `ubuntu` to spare resources
- os: ubuntu-latest
experimental: true
prefix: xvfb-run
version: '~1.10.0-0' # upcoming julia version, next `rc`
version: '~1.11.0-0' # upcoming julia version, next `rc`
- os: ubuntu-latest
experimental: true
prefix: xvfb-run
version: 'nightly'
allow_failure: true # `nightly` often breaks

steps:
- uses: actions/checkout@v4
Expand All @@ -66,7 +76,7 @@ jobs:
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.version }}
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@latest

- name: Run upstream RecipesBase & RecipesPipeline tests
Expand All @@ -90,7 +100,9 @@ jobs:
v"3.4.29" => ">=11.1,<12.1",
v"3.4.30" => ">=12.1,<13.1",
v"3.4.31" => ">=13.1,<14.1",
# ... keep this up-to-date with gcc 14
v"3.4.32" => ">=14.1,<15.1",
v"3.4.33" => ">=15.1,<16.1",
# ... keep this up-to-date with gcc 16
)[Base.BinaryPlatforms.detect_libstdcxx_version()]
("libgcc-ng$specs", "libstdcxx-ng$specs")
else
Expand Down Expand Up @@ -119,7 +131,7 @@ jobs:
if: startsWith(matrix.os, 'ubuntu')
with:
directories: RecipesBase/src,RecipesPipeline/src,src
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
if: startsWith(matrix.os, 'ubuntu')
with:
file: lcov.info
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
repository: JuliaPlots/PlotDocs.jl
- uses: julia-actions/setup-julia@latest
- name: Cache artifacts
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Create Pull Request
if: ${{ failure() }}
id: cpr
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Format .jl files [skip ci]"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ test/tmpplotsave.hdf5
/.benchmarkci
/benchmark/*.json
.vscode/
.CondaPkg/
46 changes: 22 additions & 24 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Plots"
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
author = ["Tom Breloff (@tbreloff)"]
version = "1.39.0-dev"
version = "1.40.5"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand All @@ -22,7 +22,6 @@ Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PlotThemes = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a"
PlotUtils = "995b91a9-d308-5afd-9ec6-746e21dbc043"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -41,34 +40,20 @@ UnicodeFun = "1cfade01-22cf-5700-b092-accc4b62d6e1"
UnitfulLatexify = "45397f5d-5981-4c77-b2b3-fc36d6e9b728"
Unzip = "41fe7b60-77ed-43a1-b4f0-825fd5a5650d"

[weakdeps]
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[extensions]
FileIOExt = "FileIO"
GeometryBasicsExt = "GeometryBasics"
IJuliaExt = "IJulia"
ImageInTerminalExt = "ImageInTerminal"
UnitfulExt = "Unitful"

[compat]
Aqua = "0.8"
Contour = "0.5 - 0.6"
Downloads = "1"
FFMPEG = "0.2 - 0.4"
FFMPEG = "0.3, 0.4"
FixedPointNumbers = "0.6 - 0.8"
GR = "0.69.5 - 0.73"
Gaston = "1"
HDF5 = "0.16"
InspectDR = "0.4"
HDF5 = "0.16 - 0.17"
InspectDR = "0.5"
JLFzf = "0.1"
JSON = "0.21, 1"
LaTeXStrings = "1"
Latexify = "0.14 - 0.15, 0.16"
Latexify = "0.14 - 0.16"
Measures = "0.3"
NaNMath = "0.3, 1"
PGFPlots = "3"
Expand All @@ -79,9 +64,8 @@ PlotlyBase = "0.7 - 0.8"
PlotlyJS = "0.18"
PlotlyKaleido = "1"
PrecompileTools = "1"
Preferences = "1"
PyPlot = "2"
PythonPlot = "1 - 1.0.2"
PythonPlot = "1"
RecipesBase = "1.3.1"
RecipesPipeline = "0.6.10"
Reexport = "0.2, 1"
Expand All @@ -90,13 +74,20 @@ Requires = "1"
Scratch = "1"
Showoff = "0.3.1, 1"
Statistics = "1"
StatsBase = "0.33, 0.34"
StatsBase = "0.33 - 0.34"
UnicodeFun = "0.4"
UnicodePlots = "3.4"
UnitfulLatexify = "1"
Unzip = "0.1 - 0.2"
julia = "1.6"

[extensions]
FileIOExt = "FileIO"
GeometryBasicsExt = "GeometryBasics"
IJuliaExt = "IJulia"
ImageInTerminalExt = "ImageInTerminal"
UnitfulExt = "Unitful"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Expand Down Expand Up @@ -132,4 +123,11 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92"

[targets]
test = ["Aqua", "Colors", "Distributions", "FileIO", "FilePathsBase", "FreeType", "Gaston", "GeometryBasics", "Gtk", "ImageMagick", "Images", "InspectDR", "LibGit2", "OffsetArrays", "PGFPlotsX", "PlotlyJS", "PlotlyBase", "PyPlot", "PythonPlot", "PlotlyKaleido", "HDF5", "RDatasets", "SentinelArrays", "StableRNGs", "StaticArrays", "StatsPlots", "Test", "TestImages", "UnicodePlots", "Unitful", "VisualRegressionTests"]
test = ["Aqua", "Colors", "Distributions", "FileIO", "FilePathsBase", "FreeType", "Gaston", "GeometryBasics", "Gtk", "ImageMagick", "Images", "LibGit2", "OffsetArrays", "PGFPlotsX", "PlotlyJS", "PlotlyBase", "PyPlot", "PythonPlot", "PlotlyKaleido", "HDF5", "RDatasets", "SentinelArrays", "StableRNGs", "StaticArrays", "StatsPlots", "Test", "TestImages", "UnicodePlots", "Unitful", "VisualRegressionTests"]

[weakdeps]
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
[![][docs-stable-img]][docs-stable-url]
[![][docs-dev-img]][docs-dev-url]
[![Codecov](https://codecov.io/gh/JuliaPlots/Plots.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaPlots/Plots.jl)
[![Plots Downloads](https://shields.io/endpoint?url=https://pkgs.genieframework.com/api/v1/badge/Plots)](https://pkgs.genieframework.com?packages=Plots)
[![Plots Downloads](https://img.shields.io/badge/dynamic/json?url=http%3A%2F%2Fjuliapkgstats.com%2Fapi%2Fv1%2Fmonthly_downloads%2FPlots&query=total_requests&suffix=%2Fmonth&label=Downloads)](https://juliapkgstats.com/pkg/Plots)

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4725317.svg)](https://doi.org/10.5281/zenodo.4725317)
This is the DOI for all Versions, please follow the link to get the DOI for a specific version.
Expand Down
2 changes: 1 addition & 1 deletion src/Plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@max_m
end

using Pkg, Dates, Printf, Statistics, Base64, LinearAlgebra, SparseArrays, Random
using PrecompileTools, Preferences, Reexport, RelocatableFolders
using PrecompileTools, Reexport, RelocatableFolders
using Base.Meta
@reexport using RecipesBase
@reexport using PlotThemes
Expand Down
40 changes: 12 additions & 28 deletions src/backends.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,35 +194,13 @@ end
CurrentBackend(sym::Symbol) = CurrentBackend(sym, _backend_instance(sym))

# ---------------------------------------------------------
# from github.com/JuliaPackaging/Preferences.jl/blob/master/README.md:
# "Preferences that are accessed during compilation are automatically marked as compile-time preferences"
# ==> this must always be done during precompilation, otherwise
# the cache will not invalidate when preferences change
const PLOTS_DEFAULT_BACKEND = lowercase(load_preference(Plots, "default_backend", "gr"))
const PLOTS_DEFAULT_BACKEND = "gr"

function load_default_backend()
# environment variable preempts the `Preferences` based mechanism
CURRENT_BACKEND.sym =
get(ENV, "PLOTS_DEFAULT_BACKEND", PLOTS_DEFAULT_BACKEND) |> lowercase |> Symbol
CURRENT_BACKEND.sym = :gr
backend(CURRENT_BACKEND.sym)
end

function set_default_backend!(
backend::Union{Nothing,AbstractString,Symbol} = nothing;
force = true,
kw...,
)
if backend === nothing
delete_preferences!(Plots, "default_backend"; force, kw...)
else
# NOTE: `_check_installed` already throws a warning
if (value = lowercase(string(backend))) |> _check_installed !== nothing
set_preferences!(Plots, "default_backend" => value; force, kw...)
end
end
nothing
end

function diagnostics(io::IO = stdout)
origin = if has_preference(Plots, "default_backend")
"`Preferences`"
Expand Down Expand Up @@ -1071,13 +1049,19 @@ const _pyplot_scale = [:identity, :ln, :log2, :log10]
_post_imports(::PythonPlotBackend) = @eval begin
const PythonPlot = Main.PythonPlot
const PythonCall = Main.PythonPlot.PythonCall
mpl_toolkits = PythonCall.pyimport("mpl_toolkits")
mpl = PythonCall.pyimport("matplotlib")
numpy = PythonCall.pyimport("numpy")
const mpl_toolkits = PythonPlot.pyimport("mpl_toolkits")
const mpl = PythonPlot.pyimport("matplotlib")
const numpy = PythonPlot.pyimport("numpy")

PythonCall.pyimport("mpl_toolkits.axes_grid1")
PythonPlot.pyimport("mpl_toolkits.axes_grid1")
numpy.seterr(invalid = "ignore")

const pyisnone = if isdefined(PythonCall, :pyisnone)
PythonCall.pyisnone
else
PythonCall.Core.pyisnone
end

PythonPlot.ioff() # we don't want every command to update the figure
end
_runtime_init(::PythonPlotBackend) = nothing
Expand Down
4 changes: 2 additions & 2 deletions src/backends/pgfplotsx.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
)
end
for (series_index, series) in enumerate(series_list(sp))
# give each series a uuid for fillbetween
series_id = uuid4()
# give each series an id for fillbetween
series_id = maximum(values(_pgfplotsx_series_ids), init = 0) + 1
_pgfplotsx_series_ids[Symbol("$series_index")] = series_id
opt = series.plotattributes
st = series[:seriestype]
Expand Down
2 changes: 1 addition & 1 deletion src/backends/plotly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ html_body(plt::Plot{PlotlyBackend}) = plotly_html_body(plt)

plotly_url() =
if _use_local_dependencies[]
"file:///" * _plotly_local_file_path[]
_plotly_data_url()
else
"https://cdn.plot.ly/$_plotly_min_js_filename"
end
Expand Down
14 changes: 7 additions & 7 deletions src/backends/pythonplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ _py_renderer(fig) = _py_canvas(fig).get_renderer()
_py_drawfig(fig) = fig.draw(_py_renderer(fig))

# `get_points` returns a numpy array in the form [x0 y0; x1 y1] coords (origin is bottom-left (0, 0)!)
_py_extents(obj) = PythonCall.PyArray(obj.get_window_extent().get_points())
_py_extents(obj) = PythonPlot.PyArray(obj.get_window_extent().get_points())

# see cjdoris.github.io/PythonCall.jl/stable/conversion-to-julia/#py2jl-conversion
to_vec(x) = PythonCall.pyconvert(Vector, x)
to_str(x) = PythonCall.pyconvert(String, x)
to_vec(x) = PythonPlot.pyconvert(Vector, x)
to_str(x) = PythonPlot.pyconvert(String, x)

# compute a bounding box (with origin top-left), however PythonPlot gives coords with origin bottom-left
function _py_bbox(obj)
PythonCall.pyisnone(obj) && return _py_bbox(nothing)
pyisnone(obj) && return _py_bbox(nothing)
fl, fr, fb, ft = bb = _py_extents(obj.get_figure())
l, r, b, t = ex = _py_extents(obj)
# @show obj bb ex
Expand Down Expand Up @@ -916,7 +916,7 @@ function _before_layout_calcs(plt::Plot{PythonPlotBackend})
(cmap = func(cbar_series)) === nothing || break
end
c_map = mpl.cm.ScalarMappable(; cmap, norm)
c_map.set_array(PythonCall.pylist([]))
c_map.set_array(PythonPlot.pylist([]))
c_map
else
cbar_series[:serieshandle][end]
Expand Down Expand Up @@ -1233,10 +1233,10 @@ function _before_layout_calcs(plt::Plot{PythonPlotBackend})
# link axes
x_ax_link, y_ax_link = xaxis.sps[1].o, yaxis.sps[1].o
if Bool(ax != x_ax_link) # twinx
ax.get_shared_x_axes().join(ax, x_ax_link)
ax.sharey(y_ax_link)
end
if Bool(ax != y_ax_link) # twiny
ax.get_shared_y_axes().join(ax, y_ax_link)
ax.sharex(x_ax_link)
end
end # for sp in pl.subplots
_py_drawfig(fig)
Expand Down
6 changes: 3 additions & 3 deletions src/examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ const _examples = PlotExample[
"3D axis flip / mirror",
:(using LinearAlgebra),
quote
with(scalefonts = 0.5) do
Plots.with(scalefonts = 0.5) do
x, y = collect(-6:0.5:10), collect(-8:0.5:8)

args = x, y, (x, y) -> sinc(norm([x, y]) / π)
Expand Down Expand Up @@ -1198,7 +1198,7 @@ const _examples = PlotExample[
legs,
)
w, h = Plots._plot_defaults[:size]
with(scalefonts = 0.5, size = (2w, 2h)) do
Plots.with(scalefonts = 0.5, size = (2w, 2h)) do
plot(leg_plots()..., leg_plots(legend_column = -1)...; layout = (6, 3))
end
end,
Expand Down Expand Up @@ -1230,7 +1230,7 @@ const _examples = PlotExample[
legs,
)
w, h = Plots._plot_defaults[:size]
with(scalefonts = 0.5, size = (2w, 2h)) do
Plots.with(scalefonts = 0.5, size = (2w, 2h)) do
plot(leg_plots()..., leg_plots(legend_column = -1)...; layout = (6, 3))
end
end,
Expand Down
Loading

0 comments on commit 8bf9d59

Please sign in to comment.