template to handle strings on x axis w/ legend#254
Open
impressostudios wants to merge 2 commits intolava:masterfrom
Open
template to handle strings on x axis w/ legend#254impressostudios wants to merge 2 commits intolava:masterfrom
impressostudios wants to merge 2 commits intolava:masterfrom
Conversation
bool named_plot(const std::string& name, const std::vector<std::string>& x, const std::vector<Numeric>& y, const std::string& format = "") { .. }
added template to be able to have named legend plotting: ex: time(x) vs signal(y) with legend.
Prior to this change, the current library implements simple plots with no legends and with this change the above should be possible.
hashimabdul
approved these changes
Mar 2, 2021
Owner
|
Thanks for contributing! I'm a bit confused if/why this works, it's not mentioned on the matplotlib docs that Would you mind adding an example that uses this function, so I can check out that this works as it should? |
Author
|
Hi,
This is needed as Python can handle string conversions easily for some
users.. But to look forward to similar functionality in CPP, we sometimes
need texts / name plots or here in my case I wanted to have time in
"<Month>< >Year" format on the X-Axis.
I used it to represent peak speed reached per month for a vehicle using:
plot::named_plot("Vehicle speed (max)", mon_yy, veh_spd); //
where mon_yy and veh_spd are vectors of which mon_yy is a mix of
string and numbers.
The resultant looks similar to this:
[image: image.png]
The current implementation will not accept spaces or characters as
vectors. Hence just prototyped a simple template for strings.
I hope this helps!
Thank you!
…On Fri, Apr 2, 2021 at 4:40 PM Benno Evers ***@***.***> wrote:
Thanks for contributing!
I'm a bit confused if/why this works, it's not mentioned on the matplotlib
docs that x can be a vector of strings:
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.plot.html
Would you mind adding an example that uses this function, so I can check
out that this works as it should?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#254 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKKMLTO5PKJBV7RQV6QFXY3TGYTS7ANCNFSM4YPAYPNQ>
.
|
Author
|
@lava this is open for more than 2 years. if my response answers your question, can you please merge my pull request ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bool named_plot(const std::string& name, const std::vectorstd::string& x, const std::vector& y, const std::string& format = "") { .. }
added template to be able to have named legend plotting: ex: time(x) vs signal(y) with legend.
Prior to this change, the current library implements simple plots with no legends and with this change the above should be possible.