How can I display a Matplotlib plot / chart / image in Dear PyGui? #1316
Unanswered
DataExplorerUser
asked this question in
Support
Replies: 1 comment
-
import matplotlib.pyplot as plt
import numpy as np
import dearpygui.dearpygui as dpg
from matplotlib.backends.backend_agg import FigureCanvasAgg
fig = plt.figure(figsize=(11.69, 8.26), dpi=100)
canvas = FigureCanvasAgg(fig)
ax = fig.gca()
canvas.draw()
buf = canvas.buffer_rgba()
image = np.asarray(buf)
image = image.astype(np.float32) / 255
with dpg.texture_registry():
dpg.add_raw_texture(
1169, 826, image, format=dpg.mvFormat_Float_rgba, id="texture_id"
)
with dpg.window(label="MatPlotLib"):
dpg.add_image("texture_id")
dpg.start_dearpygui() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How can I display a Matplotlib plot / chart / image in Dear PyGui?
Beta Was this translation helpful? Give feedback.
All reactions