Closed Vindaar closed 3 years ago
The original problem has been fixed by now.
The plot is still not being produced, because of a different issue. Essentially the code now tries to apply a continuous transformation in calling applyContScaleIfAny
here:
https://github.com/Vindaar/ggplotnim/blob/master/src/ggplotnim/postprocess_scales.nim#L707
but the continuous scale Values
does not exist in the DF anymore, as we called count
before:
https://github.com/Vindaar/ggplotnim/blob/master/src/ggplotnim/postprocess_scales.nim#L703
count
reduces the DF and thus drops additional columns. Because of that the formula evaluation happening in the aforementioned proc, creates a constant string column of values "Values"
. And these cannot be mapped to a continuous value, so we crash here:
https://github.com/Vindaar/ggplotnim/blob/master/src/ggplotnim/collect_and_fill.nim#L227
as we require (obviously) a constant column to be mappable to float
.
The underlying problem is nowadays that the plot we ask for isn't well defined. In a bar plot what is continuous coloring supposed to mean? Even ggplot2 produces the following plot:
> df2
# A tibble: 12 x 2
Type Values
<chr> <dbl>
1 w1 4
2 w1 39
3 w1 11
4 w2 0
5 w2 1
6 w2 1
7 w3 0
8 w3 5
9 w3 0
10 w4 2
11 w4 2
12 w4 2
> ggplot(df2, aes(Type, fill = Values)) + geom_bar()
Hmm.
Another issue discovered in the discussion with @haxscramper.
A plot with
geom_bar
values, which are filled by a continuous scale can cause a runtime error due to a failed assertion in the filling of the color scale.For the following csv file:
the code:
results in:
The current master HEAD has slightly different lines. The offending line is: https://github.com/Vindaar/ggplotnim/blob/master/src/ggplotnim/collect_and_fill.nim#L289-L291
Investigate why the evaluation of the formula yields an empty tensor!