Skip to content

do not plot legend upon single series #4964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/reference_images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Update reference images

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
repository: JuliaPlots/PlotDocs.jl
token: ${{ secrets.PLOTS_REFIMAGES_TOKEN }}
- uses: julia-actions/setup-julia@latest
with:
version: "1"
- name: Cache artifacts
uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{runner.os}}-test-${{env.cache-name}}-${{hashFiles('**/Project.toml')}}
restore-keys: |
${{runner.os}}-test-${{env.cache-name}}-
${{runner.os}}-test-
${{runner.os}}-
- name: Run Plots tests
env:
PLOTSBASE_TEST_PACKAGES: GR
VISUAL_REGRESSION_TESTS_AUTO: true
shell: julia --color=yes {0}
run: |
using Pkg
gh_ref = ${{ github.ref_name }}
@info "Adding Plots#$gh_ref"
Pkg.add(PackageSpec(name="Plots", rev="$gh_ref"))
Pkg.test("Plots")
- name: Create pull request
uses: peter-evans/create-pull-request@v7
with:
title: "Update Plot reference images from branch ${{ github.ref_name}} by the action ${{ github.workflow_ref }}"
body: "Review changes thoroughly and only merge when no unwanted chages are present."
token: ${{ secrets.PLOTS_REFIMAGES_TOKEN }}
22 changes: 11 additions & 11 deletions GraphRecipes/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ default(show = false, reuse = true)
method ≡ :spectral && continue # FIXME
dat = if (inp = GraphRecipes._graph_inputs[method]) ≡ :adjmat
[
0 1 1;
1 0 1;
0 1 1
1 0 1
1 1 0
]
elseif inp ≡ :sourcedestiny
Symmetric(sparse(rand(rng, 0:1, 8, 8)))
elseif inp ≡ :adjlist
dat = [
0 1 1 0 0 0 0 0 0 0;
0 0 0 0 1 1 0 0 0 0;
0 0 0 1 0 0 1 0 1 0;
0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 1 0 1;
0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0;
0 1 1 0 0 0 0 0 0 0
0 0 0 0 1 1 0 0 0 0
0 0 0 1 0 0 1 0 1 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
]
else
Expand Down
11 changes: 7 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@

- deprecated backends `pgfplots` and `pyplot` removed
- deprecated keyword `orientation` removed
- backends are extensions now so the backend code must be explicitly loaded using `import` with the backend package, e.g. ```julia
using Plots
import GR # loads backend code
- backends are extensions now so the backend code must be explicitly loaded using `import` with the backend package, e.g.
```julia
using Plots
import GR # loads backend code

```
```
- Types are no longer part of the Plots API this affects
- `Shape`, which is now `shape`
- The default `label` is now `:none`, use `:auto` to restore the previous behaviour

---

#### notes on release changes, ongoing development, and future planned work

## NOTE: this file is deprecated, see the [TagBot](https://github.com/marketplace/actions/julia-tagbot) auto-generated changelogs instead
Expand Down
2 changes: 1 addition & 1 deletion PlotsBase/ext/GRExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2033,7 +2033,7 @@ function gr_draw_segments(series, x, y, z, fillrange, clims)
series[:arrow] isa Arrow ? series[:arrow] : Arrow(:none, :simple, 1.0, 1.0)

arrowside, arrowstyle, arrowsize =
arrow.side, arrow.style, (arrow.headlength+arrow.headwidth)/2
arrow.side, arrow.style, (arrow.headlength + arrow.headwidth) / 2

gr_polyline(x[rng], y[rng]; arrowside, arrowstyle, arrowsize)
end
Expand Down
2 changes: 1 addition & 1 deletion PlotsBase/src/Commons/attrs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ const _bar_width = 0.8
# -----------------------------------------------------------------------------

const _series_defaults = KW(
:label => :auto,
:label => :none,
:colorbar_entry => true,
:seriescolor => :auto,
:seriesalpha => nothing,
Expand Down
2 changes: 1 addition & 1 deletion PlotsBase/src/DF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function parse_table_call!(d, x::Expr, syms, vars)
new_ex = Expr(:tuple, x.args...)

for (j, field_in_NT) ∈ enumerate(new_ex.args)
if isa(field_in_NT, Expr) && field_in_NT.head==:(=)
if isa(field_in_NT, Expr) && field_in_NT.head == :(=)
new_ex.args[j] = Expr(:(=), field_in_NT.args...)
elseif field_in_NT isa QuoteNode
new_ex.args[j] = Expr(:(=), field_in_NT.value, field_in_NT)
Expand Down
12 changes: 7 additions & 5 deletions PlotsBase/test/test_args.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ end
end

@testset "Series Attributes" begin
pl = plot([[1, 2, 3], [2, 3, 4]], lw = 5)
@test hline!(deepcopy(pl), [1.75])[1].series_list[3][:label] ==
hline!(deepcopy(pl), [1.75], z_order = :front)[1].series_list[3][:label] ==
pl = plot([[1, 2, 3], [2, 3, 4]], lw = 5, label = :auto)
@test hline!(deepcopy(pl), [1.75], label = :auto)[1].series_list[3][:label] ==
hline!(deepcopy(pl), [1.75], z_order = :front, label = :auto)[1].series_list[3][:label] ==
"y3"
@test hline!(deepcopy(pl), [1.75], z_order = :back, label = :auto)[1].series_list[1][:label] ==
"y3"
@test hline!(deepcopy(pl), [1.75], z_order = 2, label = :auto)[1].series_list[2][:label] ==
"y3"
@test hline!(deepcopy(pl), [1.75], z_order = :back)[1].series_list[1][:label] == "y3"
@test hline!(deepcopy(pl), [1.75], z_order = 2)[1].series_list[2][:label] == "y3"
sp = pl[1]
@test isempty(sp[1][:extra_kwargs])
@test sp[2][:series_index] == 2
Expand Down
2 changes: 1 addition & 1 deletion PlotsBase/test/test_misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ with(:gr) do
@test plot([0:1 reverse(0:1)]; labels = ["a" "b"], leg = (0.5, :inner)) isa
PlotsBase.Plot
@test_logs (:warn, r"n° of legend_column.*") png(
plot(1:2, legend_columns = 10),
plot(1:2, legend_columns = 10, label = :auto),
tempname(),
)
end
Expand Down
6 changes: 3 additions & 3 deletions PlotsBase/test/test_pgfplotsx.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ with(:pgfplotsx) do

@testset "Legends" begin
pl = plot(rand(5, 2), lab = ["1" ""], arrow = true)
scatter!(pl, rand(5))
scatter!(pl, rand(5), label = :auto)
axis_contents = first(get_pgf_axes(pl)).contents
leg_entries = filter(x -> x isa PGFPlotsX.LegendEntry, axis_contents)
series = filter(x -> x isa PGFPlotsX.Plot, axis_contents)
Expand Down Expand Up @@ -93,8 +93,8 @@ with(:pgfplotsx) do
end

@testset "Plot in pieces" begin
pl = plot(rand(100) / 3, reg = true, fill = (0, :green))
scatter!(pl, rand(100), markersize = 6, c = :orange)
pl = plot(rand(100) / 3, reg = true, fill = (0, :green), label = :auto)
scatter!(pl, rand(100), markersize = 6, c = :orange, label = :auto)
axis_contents = first(get_pgf_axes(pl)).contents
leg_entries = filter(x -> x isa PGFPlotsX.LegendEntry, axis_contents)
series = filter(x -> x isa PGFPlotsX.Plot, axis_contents)
Expand Down
Loading