Comments (5)
I am not really familiar with StatsPlots.jl, but if you want to tackle this issue I am happy to help with the UnitfulRecipes.jl side. My guess is that kde first performs a calculation (estimating kernel density) and then does some plotting stuff.
And the calculation is probably not compatible with units? Then one approach would be to make the calculation compatible with Unitful.jl I think and afterwards unitful plotting magically works hopefully.
from unitfulrecipes.jl.
The issue is that KernelDensity.kde()
only accepts Real
, while Unitful.Quantity isa Number
but not a Real
.
One solution to this and several similar bugs is a pretty invasive rework of Unitful
with
struct RealQuantity{T<:Real, D, U} <: Real
val::T
end
RealQuantity(q::Q) where {Q<:Unitful.Quantity} = RealQuantity{Q.parameters...}(q.val)
Another is to make kde
more permissive, using isreal
rather than dispatching with Real
if that's important.
from unitfulrecipes.jl.
I am not really familiar with StatsPlots.jl, but if you want to tackle this issue I am happy to help with the UnitfulRecipes.jl side.
- Thank you for the kind offer. Step one for me is to learn how generic Plots.jl recipes work, then UnitfulRecipes, so it might be a while yet 😄
My guess is that kde first performs a calculation (estimating kernel density) and then does some plotting stuff. And the calculation is probably not compatible with units?
- I think this is also the case. Does this mean that the Plots.jl plot types all have methods which permit Unitful data?
Then one approach would be to make the calculation compatible with Unitful.jl I think and afterwards unitful plotting magically works hopefully.
- If this is the right thing to do, I think this will be a thing to take to StatsPlots.jl in the first instance, and then return to UnitfulRecipes if needed afterward.
from unitfulrecipes.jl.
One solution to this and several similar bugs is a pretty invasive rework of
Unitful
- Thanks for your feedback!
- Good to know, though such a step is definitely beyond me (I'm an engineer rather than programmer) and I am unsure if anyone else is interested in using the StatsPlots functionality with Unitful data directly.
- Is this something that should be mentioned to the people who maintain Unitful, do you think?
In the meantime, I was able to plot what I was trying to, by, for example, doing a groupedbar()
plot with data without any units, then I needed to plot a hline()
on to this plot, which works very nicely with UnitfulRecipes, and lets the axes be scaled and the units be put onto the axes automatically with unitformat=:square
or similar.
I intend to learn more about how this works in the future, at which point perhaps I can contribute something 🤞
from unitfulrecipes.jl.
Does this mean that the Plots.jl plot types all have methods which permit Unitful data?
It's rather that through our recipes, we are telling Plots how to convert Unitful data to unitless data before any plotting is done. I can't quite figure out why no such transformation is applied for StatsPlots.
from unitfulrecipes.jl.
Related Issues (20)
- Compatibility when using two user recipes together HOT 8
- Recipe for parametric with units? HOT 14
- TagBot trigger issue HOT 16
- unitful yerr seems to break HOT 6
- Recipe request for logarithmic units HOT 6
- Vector{Any} doesn't plot HOT 4
- Shape() fails on conversion HOT 4
- `vline` and `hline` not supporting both `xunit` and `yunit` HOT 3
- Support Unitful xticks and yticks? HOT 1
- Units in colorbar clim
- No units on colorbar for 1-argument version of heatmap HOT 1
- axis labels for `plot!`
- Recipe request for Plots with ribbon keyword HOT 1
- Units from 3rd axis applied to 4th plot HOT 8
- Tuple vs Vector behavior HOT 1
- Is it neccessary that UnitfulStrings outlive the recipe? HOT 4
- The `aspect_ratio` controls the digit spacing, ignoring the units HOT 6
- Crash on annotate HOT 1
- Error with `plot!(xticks)` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unitfulrecipes.jl.