Replies: 3 comments 1 reply
-
Exactly. They are numbers that get converted into the corresponding gradient in the colormap. matplotplusplus/source/matplot/core/axes_type.h Line 1136 in 280659a To have exact colors, you would need to change the colormap to a colormap with the colors you want in sequence: auto ax = gca();
ax->colormap(/* ... */); And then give std::vector<double> color = {0.0, 1.0, 2.0, 3.0}; // ...
matplot::scatter3(x, y, z, size, color)->marker_face(true); |
Beta Was this translation helpful? Give feedback.
-
I see, thank you for the quick response! So values from color vector are mapped on interpolated colormap.
My problem is, the {0,1,2,3} ; {1,2,3,4} ; {2,3,4,5} etc. all generate same colors = lowest value Red, highest Yellow, and other are interpolated in between. To be able to choose exact color by number, I must include eg 1 and 6 in the vector, like { 1, 1, 2, 6 } or { 1, 6, 2, 3 }. |
Beta Was this translation helpful? Give feedback.
-
Great idea to divide data into subsets. I've played with it a little and came with the colororder solution and hold() function suggested in examples, because setting colormap for the next data erased the previous for whole resulting plot and I've not figured out how to prevent it. So this is it, I am going to iterate through bunch of objects with XYZ-size attributes and I will divide them to separate plotting vectors according to desired color. Then merge it all with multiplot. I just must obey the plotting order (base->highlight->etc.) to get same colors every time. Is it good idea or would you suggest something even better? int main() {
//auto [x, y, z, size] = generate_data();
auto graph = matplot::gca();
std::vector<std::string> newcolors = {"cyan", "magenta", "blue"};
matplot::colororder(newcolors);
std::vector< double> x_basic = { 1, 2 };
std::vector< double> y_basic = { 0, 0 };
std::vector< double> z_basic = { 0, 0 };
std::vector< double> size_basic = { 10, 20 };
graph->scatter3(x_basic, y_basic, z_basic, size_basic)->marker_face(true);
matplot::hold(matplot::on);
std::vector< double> x_hl = { 3, 4, 5 };
std::vector< double> y_hl = { 0, 0, 0 };
std::vector< double> z_hl = { 0, 0, 0 };
std::vector< double> size_hl = { 10, 20, 30 };
graph->scatter3(x_hl, y_hl, z_hl, size_hl)->marker_face(true);
matplot::hold(matplot::off);
matplot::show();
return 0;
} EDIT: int main() {
auto [x_basic, y_basic, z_basic, size_basic, x_hl, y_hl, z_hl, size_hl] = collectPlotData();
auto graph = matplot::gca();
graph->colororder(std::vector<std::string> {"cyan", "magenta", "blue"});
graph->hold(matplot::on);
graph->scatter3(x_basic, y_basic, z_basic, size_basic)->marker_face(true);
graph->scatter3(std::vector<double> {}, std::vector<double> {}, std::vector<double> {}, std::vector<double> {})->marker_face(true);
graph->scatter3(x_hl, y_hl, z_hl, size_hl)->marker_face(true);
graph->hold(matplot::off);
matplot::show();
return 0;
} I cleaned it up a little, seems like the line order of some functions does not matter. |
Beta Was this translation helpful? Give feedback.
-
Hi, I've found the matplot++ is very similar to matplotlib, but way faster.
I'd like to make scatter3d plot from XYZ coords with different mark sizes and different colors. I've found how to do most of it in your example plots, but I am still struggling with colors. There is an "color" example
scatter3(x, y, z, sizes, colors);
, but I am somehow missing the color pattern it generates when I change values, so I guess the fifth parameter is not connected to exact color, but gradient.I'd like to do something like this (four model points):
Is it possible to put into
scatter3
the information about point's color? Or is there any good workaround?Thank you in advance.
Beta Was this translation helpful? Give feedback.
All reactions