Sphinx Plot Directive: PyVista and Matplotlib #5951
-
Hi! Do you know if it is possible to use the Sphinx plot directives of pyvista and matplotlib side-by-side? If I add both to my Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
tkoyama010
Apr 20, 2024
Replies: 1 comment 4 replies
-
@adtzlr PyVista supports Matplotlib plots in CharMPL. I recommend to plot Matplotlib results with the PyVista plot directives. import pyvista as pv
import numpy as np
import matplotlib.pyplot as plt
w = 3
Y, X = np.mgrid[-w:w:100j, -w:w:100j]
U = -1 - X**2 + Y
V = 1 + X - Y**2
speed = np.sqrt(U**2 + V**2)
f, ax = plt.subplots()
strm = ax.streamplot(X, Y, U, V, color=U, linewidth=2, cmap='autumn')
_ = f.colorbar(strm.lines)
_ = ax.set_title('Streamplot with varying Color')
plt.tight_layout()
chart = pv.ChartMPL(f)
chart.show() |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
tkoyama010
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@adtzlr PyVista supports Matplotlib plots in CharMPL. I recommend to plot Matplotlib results with the PyVista plot directives.