import matplotlib.pyplot as plt
GRAFICAS BASICAS EN PYTHON(
GRAFICAS CON MATPLOTLIB.
# Se crea la figura y los ejes.
=plt.subplots()
fig,ax=[1,1.5,2,2.5,3],
ax.scatter(x=[1,1.5,2,1.5,1],color='red')
y4,4)
fig.set_size_inches( plt.show()
import matplotlib.pyplot as plt
=plt.subplots()
fig,ax1.5,2,3,4],[1,0.75,1.5,0.5])
ax.plot([4,4)
fig.set_size_inches( plt.show()
import matplotlib.pyplot as plt
=plt.subplots()
fig,ax2.3,4.5,1,8,10,4.5,5.6,7.6,3.4,2.4,20])
ax.boxplot([ plt.show()
import matplotlib.pyplot as plt
=plt.subplots()
fig,ax1,2,3],[3,2,1])
ax.barh([10,6) fig.set_size_inches(
import matplotlib.pyplot as plt
=plt.subplots()
fig,ax1,2,3],[3,2,1])
ax.bar([10,6) fig.set_size_inches(
import numpy as np
import matplotlib.pyplot as plt
=plt.subplots()
fig,ax
=np.random.normal(10,0.8,1000)
x10)
ax.hist(x,10,5)
fig.set_size_inches( plt.show()
graficas con PLotly.
#!pip install plotly
import plotly.express as px
import plotly.offline as pyo
pyo.init_notebook_mode()
=px.scatter(x=[0,1,2,3,4],y=[0,1,4,9,16])
fig fig.show()
import plotly.express as px
import pandas as pd
=px.line(x=[1,2,3,4],y=[1,2,3,4])
fig fig.show()
import plotly.express as px
=px.data.medals_long()
long_dfprint(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
=px.bar(long_df,x="nation",
fig="count",color="medal",
y="Podio de medallas por pais")
title fig.show()
import plotly.graph_objects as go
= ['Oxígeno','Hidrógeno','Dióxido de Carbono','Nitrógeno']
labels = [4450, 2340, 1124, 670]
values
= go.Figure(data=[go.Pie(labels=labels, values=values)])
fig fig.show()