JuliaPlots / InspectDR.jl

Fast, interactive Julia/GTK+ plots (+Smith charts +Gtk widget +Cairo-only images)
MIT License
68 stars 9 forks source link

xticks doesn't work with Plots... #23

Closed VarLad closed 3 years ago

VarLad commented 3 years ago

Example. bar(x, y, legend=:none, size=(600,400), xticks = (0:16)) doesn't work, when using Plots.jl... Note that I'm using 1.6beta

VarLad commented 3 years ago

Also, I get this warning...

julia> ┌ Warning: Use of Grisu system failed.  Number display will be degraded.
└ @ NumericIO ~/.julia/packages/NumericIO/UznSq/src/NumericIO.jl:131
VarLad commented 3 years ago

More like, there's some problem with tics in general.... Screenshot from 2021-01-17 16-48-59

Something wrong with the numbering here... Everything is getting divided by 10 or 100 here... I think...

VarLad commented 3 years ago

Didn't know InspectDR was written in Julia... Is it a 1.6 issue?

VarLad commented 3 years ago

Okay, I can confirm its a 1.6 issue.... And it seems to be a grisu issue...

ma-laforge commented 3 years ago

Sorry: Just noticed the issue you opened.

Yes: I heard they (Julia developers) were using a new algorithm instead of GRISU - but I thought they were going to keep the GRISU code around in case some algorithms (like NumericIO) depends on it.

I know it worked for Julia v1.5. It is very possible they decided to deprecate GRISU in v1.6.

So, I guess I'll have to revisit this and fix the NumericIO to support whatever superseded GRISU. Not sure how long that will take. I briefly looked at the new algorithm a few months ago. It looked like it had a completely different API.

Temporary solution: use another backend (sorry) - or stick to Julia 1.5 for now.

ma-laforge commented 3 years ago

PS InspectDR does not really support "ticks" at this time (at least, I don't remember getting around to implementing this).

You can specify the axis range, but ticks are auto-selected to best fit the axis range - sorry.

Probably not a huge overhaul to allow this, but it wasn't high on my list of priorities.

If you really want this, we could open a PR. I tend to implement features only when needed - assuming it isn't too much work/doesn't "uglify" the code too much.

(Also: my availability to implement features is somewhat sporadic at this time.)

VarLad commented 3 years ago

So, I guess I'll have to revisit this and fix the NumericIO to support whatever superseded GRISU. Not sure how long that will take. I briefly looked at the new algorithm a few months ago. It looked like it had a completely different API.

If you can do that, much appreciated😀

If you really want this, we could open a PR. I tend to implement features only when needed - assuming it isn't too much work/doesn't "uglify" the code too much.

Yeah, I'm plotting qubits histogram... where I'd like to convert numbers to binary and display them as xtics 1 should appear as |01>, 0 as |00>, 2 as |10> and 3 as |11>. I probably need to use the xformatter/xlabel here.... InspectDR oddly has the neatest/least buggy display... Its well suited to my problem😀

ma-laforge commented 3 years ago

Thank you. I'll try to take a look at fixing the GRISU->RYU issue as soon as I can. Don't know how easy that will be - and I'm currently busy with other things right now. That said, it needs to be done VERY SOON.

where I'd like to convert numbers to binary and display them as xtics

Oh: you also want to pass in your own labels, not just tick positions. That probably needs more rework than I thought. I haven't currently planned any mechanism for that (though it might not be that bad).

I'll try to take a look at that too.

InspectDR oddly has the neatest/least buggy display... Its well suited to my problem😀

That's good to know, thanks. There is alot I like about other backends, but unfortunately, I don't feel comfortable yet with their interactivity, so I keep InspectDR alive.

ma-laforge commented 3 years ago

Just tagged a new version of NumericIO.jl fixing the Grisu issue.

InspectDR still does not support custom ticks, but at least numbers should show up properly.

VarLad commented 3 years ago

Thanks a lot!!!😄 I hope that I can use custom xticks soon with InspectDR too

ma-laforge commented 3 years ago

Added support for custom ticks in InspectDR.jl v0.3.10 (just tagged).

Also made a PR to integrate this new feature in Plots.jl (pending): --> https://github.com/JuliaPlots/Plots.jl/pull/3262

For the impatient

But you could copy my inspectdr.jl file to your Plots.jl/src/backends directory if you don't want to wait.

Reminder to use:

]dev Plots

to get your Julia environment to point to the ~/.julia/dev/Plots Git repository. Just don't forget to ]free Plots once the PR gets merged - And don't forget to:

$ git pull

from that Git repository to get the newest version of Plots.jl before overwriting the src/backends/inspectdr.jl file.

Cheers!

ma-laforge commented 3 years ago

The fix is now part of Plots.jl@master.

For the impatient

You can now just ]dev Plots, update to the most recent ~/.julia/dev/Plots version of master ($ git pull), and ticks should now work.

For the patient

Next time Plots.jl gets tagged (presumably v1.10.3), the fix should be included with Plots.jl.

Comments

You might want to read about ticks=:native if you use InspectDR for panning/zooming your data: --> https://github.com/JuliaPlots/Plots.jl/issues/3263

ma-laforge commented 3 years ago

Plots.jl v1.10.3 is now tagged.

Custom tick labels should now work with InspectDR without doing anything special other than using the newest version (]update).

(Also ]free Plots if you had dev-ed it before)

Comments (repeated)

You might want to read about ticks=:native if you use InspectDR for panning/zooming your data: --> JuliaPlots/Plots.jl#3263

VarLad commented 3 years ago

Thanks!!! You acted really fast!!