-
Notifications
You must be signed in to change notification settings - Fork 833
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
Images as Axis Labels #759
Conversation
I believe the reason it fails tests on Linux and Mac is because they have a different bitmap format than Windows (the header is different) which means that this test will only pass on Windows. I had hoped using the resources instead of the filesystem would help but it turns out the same problem persists. So I guess I can either find a way to specify a cross-platform bitmap to pass into I think either way the code for generating the image shouldn't be shown as part of the demo, as a) it'd be confusing and b) it's not relevant. |
Hi @bclehmann, |
Yeah, that's a lot easier. For some reason I got it in my head that the |
I added a jpeg example, and also demonstrated how transparency in PNGs is respected. This looks great! Thanks @bclehmann Regarding the matplotlib-style example, I think the example used in this PR is better because it's simpler. I don't want this recipe be to flashy, because at a glance it looks like this library supports LaTeX but fundamentally it doesn't, so I think a subtle recipe is the way to go here 👍 |
break the Render method into multiple functions use switch expressions where possible add XML documentation to public fields
@bclehmann I refactored the AxisLabel model but left all the logic intact. I'm a bit confused about the two ScottPlot/src/ScottPlot/Renderable/AxisLabel.cs Lines 88 to 113 in d1e2d3c
I added an ScottPlot/src/ScottPlot/Renderable/AxisLabel.cs Lines 34 to 37 in d1e2d3c
Also, do you think images should be rotated automatically for vertical axes like text labels are? I guess a bool could let the user control whether this happens or not. It's a pretty niche feature, but while we're in here maybe it's a good time to add it in. Interested in your thoughts! |
I didn't bring up that matplotlib example because I wanted to steer the demo that way, I brought it up because I noticed that while this PR allows images as axis labels it doesn't allow them for the plot title. |
The numbers seem arbitrary but this is for positioning, if you replaced the fraction with 1/2 it would clip the plotting window. Image padding in pixels may make sense for aesthetic reasons (although I might suggest having separate padding for x and y).
I believe it's confusing if images are rotated by default, where it's not confusing for text. Text doesn't prescribe how it should be layouted other than the order of the characters. Images have a top and a bottom and changing those to left and right is disorienting. For example, it would be confusing to render the d_theta/dt sideways. Now it may be a decent idea as an optional setting, although I can't say that I can think of a situation where the user would want their image rotated, and I think if they wanted to draw it sideways they'd rotate it themselves. |
This commit fixes a bug where setting the title color accidentally sets the top axis tick label color
Sounds good! I implemented options for custom padding (in pixels) and give the user the ability to customize it separately for each side of the bitmap. ScottPlot/src/ScottPlot/Renderable/Axis.cs Lines 142 to 148 in 9767714
Good points about rotation - It's so easy to use This PR is looking pretty good! Thanks for all your worn on this @bclehmann! 👍 |
New Contributors:
please review CONTRIBUTING.md
Purpose:
#446 #716
Allows bitmaps to be used as axis labels.
New Functionality:
Describe what this pull request does using code and/or images.
Code:
I had wanted to use a LaTeX package for the demo but as it turns out there isn't a Nuget package which does LaTeX rendering that can easily interop with
System.Drawing
, so the images are shipped with the demo, which isn't ideal.One may also want to remove the labels on
XAxis2
andYAxis2
, as they were only added for debugging purposes.