Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Convert figure to image then output to dash

$
0
0

Hi,

I have a code that produces a figure using a matplot library. I am trying to use Dash to view the figure. Since the code is made using matplotlib I want to 1) save the fig as an image 2) output that image in the dashboard. I need to know what line of codes needed to 1) Include a place to add the image in the dash layout, 2) convert the fig into image, and 3) output the image. I am new to dash but it is a good learning :slight_smile:

Thanks!

import matplotlib.pyplot as plt
import matplotlib.patches as patches
import math
from numpy import genfromtxt

floor plan sizes

limx = (0,Ylim)
limy = (0,Xlim)

fig1 = plt.figure()
ax = fig1.add_subplot(111,aspect=“equal”)

rectangles

for o in range(0,NumberBlocks):
rect = plt.Rectangle((x1[o], y1[o]), x2[o]-x1[o], y2[o]-y1[o], color=‘gray’,fill=False)
ax.add_patch(rect)
plt.text(Alpha[o],Beta[o],Names[o],size=6)

plt.rcParams[“figure.figsize”] = [30,10]

plt.ylim(limx)
plt.xlim(limy)

fig1.show()

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271