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 in plot! #27

Closed
KristofferC opened this issue Sep 22, 2015 · 19 comments
Closed

Updating labels in plot! #27

KristofferC opened this issue Sep 22, 2015 · 19 comments

Comments

@KristofferC
Copy link
Contributor

Is there anyway in which you could specify the labels in not only the first plot. As an example:

image

The x-label defined in the second plot command is not shown.

@KristofferC
Copy link
Contributor Author

It would also be nice if you could only set the labels without plotting anything extra, for example

p = plot(rand(10))
plot!(;xlabel="label")

@tbreloff
Copy link
Member

Yeah this should be possible with most backends. I see you're using pyplot, so I'll handle that first.

I'll also add shorthands 'xlabel!()', etc. I should be able to do this today.

On Sep 22, 2015, at 5:01 AM, Kristoffer Carlsson notifications@github.com wrote:

It would also be nice if you could only set the labels without plotting anything extra, for example

p = plot(rand(10))
plot!(;xlabel="label")

Reply to this email directly or view it on GitHub.

@KristofferC
Copy link
Contributor Author

I'm using PyPlot because I'm having some troubles with the other backends in IJulia.

For example:

image

Same with Immerse and Gadfly.

@tbreloff
Copy link
Member

I'm a little confused what you're trying to do. x_mod and y_mod are not valid arguments in Plots, so I wouldn't expect this to flow through to the backends at all. Also what is matstats? Let me know how you'd like to call this, and I can either tell you the right way, or add support for it.

@KristofferC
Copy link
Contributor Author

Sorry, I understand your confusion, I should have explained better. I am writing a package where the resulting data is a bit messy to extract from the type. To facilitate plotting of the results I therefore extend the plot function in Plots.jl with another function that take the types in my package (matstat is one of those types). This function then extracts the needed data from the type and then finally calls the Plots.jl plot-function and return that plot object

However, the problem has nothing to do with this, it is just that with certain backends like Immerse, Gadfly, Winston I get no output in IJulia.

An example which does not contain any of my own code:

image

@KristofferC
Copy link
Contributor Author

Using for example Gadfly directly works.

image

@tbreloff
Copy link
Member

Ah I see, so it's just not displaying in IJulia. Ok I need to look into that... I don't actually use IJulia at all, but I know others do, so I want that to work as expected.

@tbreloff
Copy link
Member

Just installed IJulia, so I'll investigate further. However, does it work if you do:

using Plots
gadfly!()
plot(rand(10))
display(currentPlot())

@KristofferC
Copy link
Contributor Author

Cool! That works beautifully for Gadfly and Immerse (Immerse opens a new window but I guess this is to expect since it has the GUI functionality).

For Winston (works with using Winston):

LoadError: MethodError: `display` has no method matching display(::Gtk.GtkCanvas, ::Winston.FramedPlot)
Closest candidates are:
  display(!Matched::AbstractString, ::Any)
  display(!Matched::TextDisplay, ::Any)
  display(!Matched::MIME{mime}, ::Any)
  ...

@tbreloff
Copy link
Member

Ok thanks. I'll look into Winston, but I suspect that IJulia calls a
specific "writemime" method to show its results, and my display method is
only getting called from the REPL. It should be a relatively easy fix, as
soon as I figure out the specific problem.

On Tue, Sep 22, 2015 at 11:08 AM, Kristoffer Carlsson <
notifications@github.com> wrote:

Cool! That works beautifully for Gadfly

For Winston (works with using Winston):

LoadError: MethodError: display has no method matching display(::Gtk.GtkCanvas, ::Winston.FramedPlot)
Closest candidates are:
display(!Matched::AbstractString, ::Any)
display(!Matched::TextDisplay, ::Any)
display(!Matched::MIME{mime}, ::Any)
...


Reply to this email directly or view it on GitHub
#27 (comment).

@tbreloff
Copy link
Member

By the way, this works on the development branch, and I'll push it to master once I finish with a display/writemime re-write.

using Plots
plot(rand(10))
plot!(title="title", ylabel="ylabel")
xlabel!("xlabel")   # shorthand for plot!(xlabel="xlabel")

@tbreloff
Copy link
Member

Both the original labels/title request, and the IJulia display issues should all be fixed now on latest master. Please try it out.

@KristofferC
Copy link
Contributor Author

Works great! Thanks!

@tbreloff
Copy link
Member

Cool! If there's anything that's not easy or intuitive, please let me
know. I want this to be the kind of package that "just works" no matter
what you throw at it.

On Wed, Sep 23, 2015 at 10:00 AM, Kristoffer Carlsson <
notifications@github.com> wrote:

Works great! Thanks!


Reply to this email directly or view it on GitHub
#27 (comment).

@KristofferC
Copy link
Contributor Author

One thing, for Gadfly this works great:

image

For Pyplot I get two outputs, one that is above the Out:

image

Winston works.

Unicodeplots workish (maybe this is a limitation with the backend):

image

@tbreloff
Copy link
Member

Thanks... I'll look into PyPlot's double-display. As for UnicodePlots, that's more of a REPL plotting tool... I'm actually surprised it does anything even remotely good in IJulia!

@tbreloff
Copy link
Member

Also one additional comment... unless you need the plot reference p somewhere later in your code, it's unnecessary. Instead of

pyplot!()
p = plot(rand(10))
plot!(p, rand(10))

you can do:

pyplot!()
plot(rand(10))
plot!(rand(10))

Plots keeps track of the "current plot" for you, and when you leave it out it will automatically update the current plot.

@tbreloff
Copy link
Member

I pushed to master. The pyplot double-show issue is still there, and is not an immediately easy solution. The pyplot code is a little hacky to get it to work in IJulia, and the figure seems to be displayed at various stages of the building process, and not after the plot method returns. It works fine at the REPL, so I need to pour through Steven's code a little more to understand what he's doing for IJulia.

@tbreloff tbreloff reopened this Sep 23, 2015
@tbreloff
Copy link
Member

closing for more specific issue #29

t-bltg pushed a commit that referenced this issue Oct 6, 2022
t-bltg pushed a commit that referenced this issue Oct 6, 2022
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