Created
August 14, 2020 00:06
-
-
Save jlggross/5559ae6d961ae79bf18bfb7a5dba0270 to your computer and use it in GitHub Desktop.
Gráfico de distribuição em Python
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 pandas as pd | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
from datetime import datetime | |
bins = 20 | |
# Criando o ambiente do gráfico | |
sns.set_style("white") | |
fig, ax = plt.subplots(1, 1, figsize=(15, 10)) | |
# Insere curva KDE (Kernel Density Estimation) | |
g1 = sns.distplot(df98["Taxa %"], ax=ax, | |
kde=True, hist=False) | |
# Insere histograma | |
ax_copy = ax.twinx() | |
g2 = sns.distplot(df98["Taxa %"], ax=ax_copy, kde=False, hist=True, | |
bins=bins, norm_hist=False) | |
# Ajusta rótulos | |
g1.set_ylabel("Probabilidade") | |
g2.set_ylabel("Qauantidade") | |
g2.set_title("BTC BTG Pactual - " + datetime.now().strftime("%Y-%m-%d %H:%M")) | |
g1.xaxis.set_major_locator(ticker.MultipleLocator((df98["Taxa %"].max()-df98["Taxa %"].min())/bins)) | |
plt.setp(ax.get_xticklabels(), rotation=45) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment