Skip to content
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

Updating labels with plot! #62

Closed
joshday opened this issue Nov 5, 2015 · 5 comments
Closed

Updating labels with plot! #62

joshday opened this issue Nov 5, 2015 · 5 comments

Comments

@joshday
Copy link
Contributor

joshday commented Nov 5, 2015

At least for Gadfly and PyPlot backends,

This works as expected:

plot(randn(100,2), label = ["one" "two"])

Whereas this does not:

plot(randn(100,2))
plot!(label = ["one" "two"])

Would it also be possible to allow label to accept a Vector?

@tbreloff
Copy link
Member

tbreloff commented Nov 5, 2015

Both requests might be tough, though I can see why you want it. Series are made in one pass, although you can update plot-wide settings after the fact. I'll brainstorm on it a little, but it would probably require a redesign of some core pieces. Something like an "update series" mechanic (which would be good to have in general). I'll keep you posted.

@tbreloff
Copy link
Member

tbreloff commented Nov 5, 2015

As for Vector vs Matrix... I don't think I'm going to change that, as it's important for distinguishing between vectors that apply to all series vs matrices that map a column to a series.

@joshday
Copy link
Contributor Author

joshday commented Nov 5, 2015

Ah, I didn't realize that distinction between giving an argument a Vector vs. Matrix. That makes sense.

@tbreloff
Copy link
Member

tbreloff commented Nov 5, 2015

I thought about it, and I'm going to do a slight redesign to make it easier to update series (and improve some other stuff along the way).

@tbreloff
Copy link
Member

6 months later...

It's not perfect, but it works for me:

using Plots
p = plot(rand(10), size=(300,300))

tmp

p.series_list[1].d[:label] = "Look ma... a new label"; p

tmp

t-bltg pushed a commit that referenced this issue Oct 6, 2022
allow `return` in `@recipe`
t-bltg pushed a commit that referenced this issue Oct 6, 2022
t-bltg added a commit that referenced this issue Oct 6, 2022
* use Dates

* Add compat for RecipesBase

* Fix badges

* Plots test

* Fix travis

* Forgot using

* Update .travis.yml

Co-Authored-By: Anshul Singhvi <[email protected]>

* Use ds/rewrite

* Try with --project


Credit: Fredrik Ekre

* Use latest stable julia version

* Allow failures on MacOS

* Docs deployment

* Literate + enable deploy

* Update Project.toml

* fix missing comma

* Fix error

* try fixing repo name

* small change to trigger CI

* play better with Literate

* allow type recipes for `Number`s in arrays and surfaces

* small fixes

* skip maybestrings

* fix ambiguity

* Add badge

* Fix build badge link

* Show status only for master branch

* Fix README docs link

* remove subdomain

* Create TagBot.yml

* fix surface type recipe

* bump version

* fix error for grouping

* bump version

* further grouping fixes

* bump version

* fix plotting functions

* bump version

* downgrade version

* fix plotting rowvector of functions

* bump version

* support parametric type in `@userplot`

* add docs for parametric type in `@userplot`

* bump version

* fix grouping

* bump version

* bump PlotUtils compat

* bump version

* add zulip chat link to readme [skip ci]

* add zulip link [skip ci]

* Fix typo in docs

`AbstractArry` -> `AbstractArray`

* add hook after series decomposition (#52)

* add process_sliced_series_attributes!

* export process_slice_series_attrributes!

* remove `kw`

* Update Project.toml

[skip ci]

* Initial pass at CI

* Add script from Plots

* Update to MakieRecipes

* comment out artifact uploads

* Plots test

* CairoMakie tests

* Forgot using

* Update .travis.yml

Co-Authored-By: Anshul Singhvi <[email protected]>

* Use ds/rewrite

* Try with --project

* Another try

Credit: Fredrik Ekre

* Import examples from MakieRecipes

* add separately

* dev

* $(mktemp -d)

* Update .github/workflows/CI.yml

Co-Authored-By: Anshul Singhvi <[email protected]>

* use temp_for_test

* fix typo

* Update .github/workflows/CI.yml

* ensure that images are uploaded

* Pass a begin block to testset

* fix the macro

* seriously, I forgot .png?

* Update .travis.yml

* Fix split_attribute (#53)

* Fix a typo in the `recipe_pipeline!` constructor (#54)

* bump version

* fix time and period recipes

* bump version

* Fix typo (#56)

* implement `Base.axes` for `Volume`

* bump version

* Update group.jl

* implement iterate for Surface and Volume

* bump version

* use NaNMath log functions

* Add one_arg_shorthands macro (#73)

* Add one_arg_shorthands macro

* export one_arg_shorthands

* patch version [skip ci]

* Add :mesh3d as 3d series type (#62)

* 0.1.12 [skip ci]

* add compat for NaNMath

* dispatch processing of axis args on the plot object (#63)

* dispatch processing of axis args on the plot object

* Update type_recipe.jl

* Update type_recipe.jl

* Update type_recipe.jl

* add to API

* Update api.jl

* 0.1.13

* remove one_arg_shorthands macro (#74)

It didn't work out as intended

* 1.1.0

* more friendly error when x,y shape mis-match

* AbstractDict plot sorted

* more friendly error when x,y shape mis-match (#65)

* more friendly error when x,y shape mis-match

* don't touch z

* Update src/user_recipe.jl

Co-authored-by: Daniel Schwabeneder <[email protected]>

* switch to github-actions and update runtests.jl to run Plots test images

* update CI.yml

* keep makie tests

* move `signature_string` to RecipesPipeline

* minor version bump

* Revert "minor version bump"

This reverts commit 63c713b7808adf305484a9724cef9eabae2a0702.

* move `warn_on_recipe_aliases!` from Plots and add some `@nospecialize`

* add CompileBot

* minor version bump

* add precompile statements

* bump version

* add new line at end of file

* add recipe for list of NamedTuples

* add newline

* update tagbot action

* add recipe for list of NamedTuples

* move `warn_on_recipe_aliases!` from Plots and add some `@nospecialize`

* update tagbot action

* Fix broken histogram and stepbins plotting

* Increase package version to v0.2.1

* Update precompile_*.jl file

* add TestImages test dependency

* refine friendly error (#75)

* Update precompile_*.jl file

* don't stringify argument to `warn_on_recipe_aliases!` early
needs matching Plots changes

* minor release

* add `@nospecialize` annotations

* release

* update CompileBot

* update TESTCMD in CI

* fix TESTCMD in compilebot action

* Update precompile_*.jl file

* release

* Update README.md

[skip ci]

* don't catch all the MethodErrors (#87)

* don't catch all the MethodErrors

* remove `@show`

* 0.3.3 [skip ci]

* add mesh3d for GR

* v0.3.4

* Small improvement in inferrability (#82)

* 1.1.2 [skip ci]

* CI: tentative fix

* CI: add LinearAlgebra (#96)

Co-authored-by: t-bltg <[email protected]>

* Test for error value from `apply_recipe` fallback. (#95)

* v0.3.5 [skip ci]

* Add `Downloads` test dependency

Complement #3766

* Remove try/catch needed for compatibility with Plots.jl v1.21.0 and earlier (#97)

* Improve groups perf from O(MxN) to O(M) (#98)

* Update MakieRecipes URL

* Update precompile_*.jl file (#91)

* v0.3.6 [skip ci]

* Revert try/catch for patch version

* v0.3.7 (#101) [skip ci]

* v0.4.0 (#102) [skip ci]

* Avoid Vararg UnionAll dispatch (#104)

* Avoid Vararg UnionAll dispatch

Fixes JuliaPlots/RecipesPipeline.jl#103

* fix fix

Co-authored-by: Simon Christ <[email protected]>

* 0.4.1 [skip ci]

* move layout macro from plots (#85)

* 1.2.0 [skip ci]

* remove pct

* 1.2.1 [skip ci]

* Update Project.toml

* respect defaults for fillrange and ribbon (#106)

* respect defaults for fillrange and ribbon

* remove fillrange and ribbon handling from RecipesPipeline

* update ci

* set version

* Update CI.yml

* move documentation to gh-actions

* update run commands

* Update Documentation.yml

* Allow `NanMath` 1.0 - bump version (#108)

Co-authored-by: t-bltg <[email protected]>

* Fix `unzip` for empty vectors (#110)

* 0.5.2 [skip ci]

* update url with https://docs.juliaplots.org/stable/generated/supported/#Keyword-Arguments (#89)

* Update precompile_*.jl file (#109)

Co-authored-by: t-bltg <[email protected]>

* run  snoopcompile on pust to master only

* update compat bounds (#111)

* 0.6.0 [skip ci]

* Update precompile_*.jl file (#112)

Co-authored-by: t-bltg <[email protected]>

* `SnoopCompile` labels

* use ssh key for `TagBot` (#91)

* fix julia scripts in markdown (#90)

* add missing language specification in md

* replace type with struct

* fix `SnoopCompile` (#113)

* update compat bounds

* run snoop on master only

* update precompile

* Update precompile_*.jl file (#114)

Co-authored-by: t-bltg <[email protected]>

* 0.6.1 [skip ci]

* fix plotting `Union{Missing,Real}` arrays (#116)

* Update precompile_*.jl file (#115)

Co-authored-by: t-bltg <[email protected]>

* 0.6.2 [skip ci]

* fix formatters (#118)

* 0.6.3 [skip ci]

* Update precompile_*.jl file (#117)

Co-authored-by: BeastyBlacksmith <[email protected]>

* Create invalidations.yml (#93)

This is based on https://github.com/julia-actions/julia-invalidations. Adding such checks came up in https://discourse.julialang.org/t/potential-performance-regressions-in-julia-1-8-for-special-un-precompiled-type-dispatches-and-how-to-fix-them/86359. I suggest to add this check here since this package is widely used as a dependency.

* rework precompilation using `SnoopPrecompile` - document `@layout` (#94)

* document `@layout`

* rewok precompile statements using `SnoopPrecompile`

* add ci

* bump julia to `1.6` for failing CI

* 1.3.0

* more efficient `DefaultsDict` iteration (#121)

* bump julia version in `ci` (#122)

* 0.6.4

* Add methods to access separate keysets of the DefaultsDict (#124)

* bump version [skip ci]

* DefaultsDict - correctness and performance tweaks for large numbers of series (#126)

* 0.6.6 [skip ci]

* Fix a deprecated syntax in docs of macro `@recipe` (#95)

* fix broken docs

* remove

* remove un-needed files

* RP tests

Co-authored-by: Daniel Schwabeneder <[email protected]>
Co-authored-by: Sebastian Micluța-Câmpeanu <[email protected]>
Co-authored-by: Sebastian Micluța-Câmpeanu <[email protected]>
Co-authored-by: Anshul Singhvi <[email protected]>
Co-authored-by: Lirimy <[email protected]>
Co-authored-by: mtsch <[email protected]>
Co-authored-by: Simon Christ <[email protected]>
Co-authored-by: JonasIsensee <[email protected]>
Co-authored-by: Michael Abbott <me@pseudomac>
Co-authored-by: Benoit Pasquier <[email protected]>
Co-authored-by: Michael Krabbe Borregaard <[email protected]>
Co-authored-by: Adrian Dawid <[email protected]>
Co-authored-by: Moelf <[email protected]>
Co-authored-by: Oliver Schulz <[email protected]>
Co-authored-by: daschw <[email protected]>
Co-authored-by: Moelf <[email protected]>
Co-authored-by: Jeremy Bejanin <[email protected]>
Co-authored-by: t-bltg <[email protected]>
Co-authored-by: Tim Holy <[email protected]>
Co-authored-by: Nicholas Bauer <[email protected]>
Co-authored-by: Mike Keehan <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Christopher Rackauckas <[email protected]>
Co-authored-by: Kristoffer Carlsson <[email protected]>
Co-authored-by: Yuto Horikawa <[email protected]>
Co-authored-by: Rafael Schouten <[email protected]>
Co-authored-by: MrHenning <[email protected]>
Co-authored-by: BeastyBlacksmith <[email protected]>
Co-authored-by: Hendrik Ranocha <[email protected]>
Co-authored-by: Ryan <[email protected]>
lmiq added a commit to lmiq/Plots.jl that referenced this issue Nov 14, 2023
If the size parameter of the plot is provided in the wrong format, provide a sensible error message. Current the behavior does not provide an indication on where the input problem is:

```julia
julia> using Plots

julia> plot(size=())
Error showing value of type Plots.Plot{Plots.GRBackend}:
ERROR: BoundsError: attempt to access Tuple{} at index [1]
Stacktrace:
  [1] indexed_iterate
    @ Base ./tuple.jl:92 [inlined]
  [2] indexed_iterate(t::Tuple{}, i::Int64)
    @ Base ./tuple.jl:92
  [3] prepare_output(plt::Plots.Plot{Plots.GRBackend})
    @ Plots ~/.julia/packages/Plots/sxUvK/src/plot.jl:234
  [4] display(::Plots.PlotsDisplay, plt::Plots.Plot{Plots.GRBackend})
    @ Plots ~/.julia/packages/Plots/sxUvK/src/output.jl:168
  [5] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:340
  [6] #invokelatest#2
    @ Base ./essentials.jl:887 [inlined]
  [7] invokelatest
    @ Base ./essentials.jl:884 [inlined]
  [8] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{…})
    @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:315
  [9] (::REPL.var"JuliaPlots#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:284
 [10] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:569
 [11] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:282
 [12] (::REPL.var"#do_respond#80"{…})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:911
 [13] #invokelatest#2
    @ Base ./essentials.jl:887 [inlined]
 [14] invokelatest
    @ Base ./essentials.jl:884 [inlined]
 [15] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:2656
 [16] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1312
 [17] (::REPL.var"JuliaPlots#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:386
Some type information was truncated. Use `show(err)` to see complete types.
```
which when in the middle of a larger script can be really hard to track, as the error only manifest when the figure is being shown or saved. 

With this change, we get:

```julia
julia> plot(size=())
Error showing value of type Plots.Plot{Plots.GRBackend}:
ERROR: ArgumentError: size must be a tuple of length 2
Stacktrace:
```

and

```julia
julia> plt = plot(size = ());

julia> savefig(plt, "teste.png")
ERROR: ArgumentError: size must be a tuple of length 2
```

Which are much more clear.
Jonas-a-Zimmermann pushed a commit to Jonas-a-Zimmermann/Plots.jl that referenced this issue Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants