GRAFICAS BASICAS EN PYTHON(

GRAFICAS CON MATPLOTLIB.

import matplotlib.pyplot as plt
# Se crea la figura y los ejes.
fig,ax=plt.subplots()
ax.scatter(x=[1,1.5,2,2.5,3],
y=[1,1.5,2,1.5,1],color='red')
fig.set_size_inches(4,4)
plt.show()

import matplotlib.pyplot as plt
fig,ax=plt.subplots()
ax.plot([1.5,2,3,4],[1,0.75,1.5,0.5])
fig.set_size_inches(4,4)
plt.show()

import matplotlib.pyplot as plt
fig,ax=plt.subplots()
ax.boxplot([2.3,4.5,1,8,10,4.5,5.6,7.6,3.4,2.4,20])
plt.show()

import matplotlib.pyplot as plt
fig,ax=plt.subplots()
ax.barh([1,2,3],[3,2,1])
fig.set_size_inches(10,6)

import matplotlib.pyplot as plt
fig,ax=plt.subplots()
ax.bar([1,2,3],[3,2,1])
fig.set_size_inches(10,6)

import numpy as np
import matplotlib.pyplot as plt
fig,ax=plt.subplots()

x=np.random.normal(10,0.8,1000)
ax.hist(x,10)
fig.set_size_inches(10,5)
plt.show()

graficas con PLotly.

#!pip install plotly
import plotly.express as px
import plotly.offline as pyo
pyo.init_notebook_mode()
fig=px.scatter(x=[0,1,2,3,4],y=[0,1,4,9,16])
fig.show()
import plotly.express as px
import pandas as pd
fig=px.line(x=[1,2,3,4],y=[1,2,3,4])
fig.show()
import plotly.express as px
long_df=px.data.medals_long()
print(long_df)
        nation   medal  count
0  South Korea    gold     24
1        China    gold     10
2       Canada    gold      9
3  South Korea  silver     13
4        China  silver     15
5       Canada  silver     12
6  South Korea  bronze     11
7        China  bronze      8
8       Canada  bronze     12
fig=px.bar(long_df,x="nation",
y="count",color="medal",
title="Podio de medallas por pais")
fig.show()
import plotly.graph_objects as go

labels = ['Oxígeno','Hidrógeno','Dióxido de Carbono','Nitrógeno']
values = [4450, 2340, 1124, 670]

fig = go.Figure(data=[go.Pie(labels=labels, values=values)])
fig.show()