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

Missing values #384

Closed
Mattriks opened this issue Jan 31, 2020 · 2 comments · Fixed by #397
Closed

Missing values #384

Mattriks opened this issue Jan 31, 2020 · 2 comments · Fixed by #397

Comments

@Mattriks
Copy link
Member

Mattriks commented Jan 31, 2020

Currently Compose does not handle the Missing type. But the basis of Compose is Measure units, so all numbers are converted to Measure units anyway, including NaNs (either natively supported by Compose's graphical backends or already handled in Compose).
This means that there is a simple fix to supporting the Missing type in Compose:

Compose.x_measure(a::Missing) = Compose.x_measure(NaN)
Compose.y_measure(a::Missing) = Compose.y_measure(NaN)

y = [rand(5); missing; rand(4)]
points = collect(Tuple, zip(1:10, y))
compose(context(units=UnitBox(0,0, 10, 1)), line([points]), stroke("black") )

Missing

This fix would pave the way for supporting Missing values in Gadfly, because it means that Compose won't error when it comes to drawing the plot.

Comments? If none, I'll open a PR here sometime.

@bjarthur
Copy link
Member

bjarthur commented Feb 2, 2020

seems reasonable. let's do it!

@Mattriks
Copy link
Member Author

Mattriks commented Feb 2, 2020

I'll also work on fixing some other problems in Compose. The next example works for PNG, but for SVG the black line gets truncated, and the red line doesn't appear.

x = 1:8
p1 = collect(Tuple, zip(x, [rand(2); NaN; 0.4; NaN; rand(3)]))
p2 = collect(Tuple, zip(x, [NaN; rand(7)]))

p = compose(context(units=UnitBox(0,0, 10, 1)), 
    (context(), rectangle(), fill(nothing), stroke("gray")),
    (context(), line([p1]), stroke("black")),
    (context(), line([p2]), stroke("red"))  
)
draw(SVG(), p) # problems 
draw(PNG(), p) # no problems

iss1391

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

Successfully merging a pull request may close this issue.

2 participants