Created
June 7, 2021 10:53
-
-
Save thaisviana/e7f5ce4085683480a767c9adcb0b1794 to your computer and use it in GitHub Desktop.
grafico.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import matplotlib.backends.backend_agg as agg | |
import pylab | |
matplotlib.use("Agg") | |
def desenha_grafico(param1, param2): | |
print(param1, param2) | |
fig, ax = plt.subplots() | |
ax = fig.gca() | |
# Example data | |
people = ('A', 'B', 'C', 'D', 'E') | |
y_pos = np.arange(len(people)) | |
barra_y = [10, 2, 6, 8, 5] | |
ax.barh(y_pos, barra_y, align='center') | |
ax.set_yticks(y_pos) | |
ax.set_yticklabels(people) | |
ax.set_xlabel('Número aleatórios') | |
ax.set_title('Exemplo') | |
canvas = agg.FigureCanvasAgg(fig) | |
canvas.draw() | |
renderer = canvas.get_renderer() | |
raw_data = renderer.tostring_rgb() | |
return canvas, raw_data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment