You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am trying to label two specific plots in my diagram with a legend. The figure actually has multiple other plots, but they get labelled as data 1 data 2 and so on which I do not want. Is there a way to hide the other unnamed legends? Such as in the example below: y2 gets labelled as data1. Is there a way to not show y2 in the legend?
#include <matplot/matplot.h>
int main() {
using namespace matplot;
auto x = linspace(0, pi);
auto y1 = transform(x, [](double x) { return cos(x); });
auto y2 = transform(x, [](double x) { return cos(2 * x); });
auto y3 = transform(x, [](double x) { return cos(3 * x); });
auto p1 = plot(x, y1);
hold(on);
plot(x, y2);
auto p3 = plot(x, y3);
hold(off);
::matplot::legend({p1, p3}, {"First", "Third"});
show();
return 0;
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I am trying to label two specific plots in my diagram with a legend. The figure actually has multiple other plots, but they get labelled as data 1 data 2 and so on which I do not want. Is there a way to hide the other unnamed legends? Such as in the example below: y2 gets labelled as data1. Is there a way to not show y2 in the legend?
Beta Was this translation helpful? Give feedback.
All reactions