-
Notifications
You must be signed in to change notification settings - Fork 15
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
[feature request] Specify marker locations on the plot #43
Comments
For the time being I'd propose to just do this manually. You can do that by selecting the data you want to highlight and then adding another NOTEOk, while testing just this, I noticed a regression in the below. Namely, the color of the specific markers is overridden by the coloring given by the classification of the two channels. Using one of the recipes as an example, let's say we want to highlight min and max of channel 2 below: import ggplotnim, algorithm
let df = toDf(readCsv("data/50-18004.CSV"))
.gather(["C1_in_V", "C2_in_V"], key = "Channel", value = "V")
# filter to Channel 2 and sort by voltage
let dfSorted = df.filter(f{"Channel" == "C2_in_V"})
.arrange("V", SortOrder.Descending)
# get min and max
let dfMax = dfSorted.head(1)
let dfMin = dfSorted.tail(1)
ggplot(df, aes("in_s", "V", color = "Channel")) +
geom_line() +
# add additional geom with `data =` arg
geom_point(data = dfMax,
color = parseHex("FF0000"),
size = 5.0) +
geom_point(data = dfMin,
color = parseHex("FF0000"),
size = 5.0) +
ggsave("custom_annotate_marker.png") Which gives us the following plot: Aside from the aforementioned regression, this is lacking in another regard: at the moment the So.. aehm, if you like drawing "cairo style" feel free to implement as many marker kinds as you like, haha. I'll finish up that annotation PR first and then take a look at the performance issue. A more convenient highlighting of points will come later at some point. :) |
Ok, I just thought a bit about the regression I mention in the last post. The problemStrictly speaking what I call a regression above is one, but from a practical standpoint it's the desired behavior I would argue. A reduced and clearer example: ggplot(df, aes("in_s", "V", color = "Channel")) +
geom_line() +
geom_point(data = dfMax,
color = parseHex("FF0000"),
size = 5.0) +
ggsave("test.pdf") This should result in a plot with multi colored lines and the maximum point shown as a large circle in the given color. I mention above that the However, by doing this we would rob us from being able to just set a single column differently, e.g. if we have columns By design there does not have to be a way to undeclare an Also implementing this behavior would require rethinking the "inheritance logic" for the The alternativeWhat I did not consider in the above example, is the obvious. If the user hands a specific color, size etc. Any customization argument, we better use it! To properly handle this I need to change the I'll introduce a |
I got confused by that, but then I saw in https://vindaar.github.io/ggplotnim/#geom_point%2CAesthetics%2CColor%2Cfloat%2Cstring%2Cfloat%2Cseq%5BT%5D%5Bfloat%5D%2Cstring%2Cstring that So you can specify the color using the
That's a nice idea.. Can then the |
No, you have to differentiate between the
This means each value in the given column refers to a value on the desired scale, which is used to customize the appearance or location of a geom to be drawn. (As an aside: You can also assign a string, which is not a DF column and it'll use that as a dummy value. In effect this gets you a legend for those set values and a unique style for them. In the future this should be extended to formulas etc., so that one can say things like On the other hand customizing the appearance without an associated scale is what's called setting a style. This is done via the direct The final style a point, line etc. will have is thus a combination of mappings and settings. My confusion was simply that I didn't think about the priorities before. In practice the user will usually only define mappings on the data. However, if they do provide a setting that probably means they want to override a specific mapping for something. And that should be possible (and it doesn't work correctly right now). I haven't completely read it right now, but I think this article explains a little more about the difference of mappings and settings in
As mentioned above, that's not really possible. |
Oops, sorry, I did not realize this distinction.
👍 |
With #48 merged the priority issue mentioned above is now addressed. That means the example given in my first comment now works as expected (see The setting arguments require an I'll leave this issue open as a reminder that convenient highlighting is something we might want to support in the future. |
#56 is about to be merged, which finally introduces See the recipe (especially |
Hello,
I was compounding a related feature request in the "annotation feature request" issue. So instead I broke it out to this separate issue.
Can the A, B, C, D, E points put as some kind of markers on that line plot in your example?
.. something like the star markers that a user might choose to place in this MATLAB example (see below): https://www.mathworks.com/help/matlab/creating_plots/create-line-plot-with-markers.html#bvcbmly-1
Originally posted by @kaushalmodi in #37 (comment)
The text was updated successfully, but these errors were encountered: