Skip to content

Adds plot_surface function overloading#232

Open
antoinedray wants to merge 2 commits intolava:masterfrom
antoinedray:wip/gca-multi-surface
Open

Adds plot_surface function overloading#232
antoinedray wants to merge 2 commits intolava:masterfrom
antoinedray:wip/gca-multi-surface

Conversation

@antoinedray
Copy link
Copy Markdown

Added:

Adds bindings to the figure's gca method (matplotlib.figure.Figure.gca):

inline void gca(const std::string projection = "3d")

This allows display of multiple surfaces on the same figure.

See example below:

plt::gca("3d");
plt::plot_surface(x1, y1, z1, {{"cmap", "Blues"}});
plt::plot_surface(x2, y2, z2, {{"cmap", "Reds"}});
plt::show();

Enable surfaces superposition in the same figure by calling the gca method before the plot_surface methods
@antoinedray antoinedray changed the title Adds figure's gca method to allow for surfaces superposition Adds figure's gca method bindings for surfaces superposition in figure Oct 9, 2020
@antoinedray
Copy link
Copy Markdown
Author

Update:

Remove gca method as it conflicts with simple surface plotting.

New technique found instead:

Adds plot_surface function overloading:

template <typename Numeric>
void plot_surface(long figure,
                  const std::vector<::std::vector<Numeric>> &x,
                  const std::vector<::std::vector<Numeric>> &y,
                  const std::vector<::std::vector<Numeric>> &z,
                  const std::map<std::string, std::string> &keywords = std::map<std::string, std::string>())

By passing the figure id as parameter, it is now possible to bring multiple surfaces in the same figure:

long id = plt::figure();
plt::plot_surface(id, x1, y1, z1, {{"cmap", "Blues"}});
plt::plot_surface(id, x2, y2, z2, {{"cmap", "Reds"}});
plt::show();

@antoinedray antoinedray changed the title Adds figure's gca method bindings for surfaces superposition in figure Adds plot_surface function overloading Nov 9, 2020
@bingjingshidelei
Copy link
Copy Markdown

Why did I use the second drawing method, instead of drawing the two surfaces in the same display, I just showed the first of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants