Quiero generar un par de curvas en forma de campana con fines demostrativos.
Las curvas no se calculan sobre datos reales; Debería poder especificar una desviación estándar y una media para cada color, y lo dibuja muy bien para mí.
¿Existe una herramienta en línea o una herramienta simple o una biblioteca que pueda hacer esto por mí?
En python usando numpy y matplotlib puede hacer esto con bastante facilidad, el siguiente es uno de los ejemplos:
"""
Demo of the histogram (hist) function with a few features.
In addition to the basic histogram, this demo shows a few optional features:
* Setting the number of data bins
* The ``normed`` flag, which normalizes bin heights so that the integral of
the histogram is 1. The resulting histogram is a probability density.
* Setting the face color of the bars
* Setting the opacity (alpha value).
"""
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
# example data
mu = 100 # mean of distribution
sigma = 15 # standard deviation of distribution
x = mu + sigma * np.random.randn(10000)
num_bins = 50
# the histogram of the data
n, bins, patches = plt.hist(x, num_bins, normed=1, facecolor='green', alpha=0.5)
# add a 'best fit' line
y = mlab.normpdf(bins, mu, sigma)
plt.plot(bins, y, 'r--')
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title(r'Histogram of IQ: $\mu=100$, $\sigma=15$')
# Tweak spacing to prevent clipping of ylabel
plt.subplots_adjust(left=0.15)
plt.show()
Si simplemente tiene 2 valores para mu y sigma (o solicitarlos), omita las etiquetas y el título, etc.
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
num_bins = 50
for mu, sigma, col, line in [(120, 15, 'red', 'r-'), (80,20, 'green', 'g-')]:
x = mu + sigma * np.random.randn(10000)
n, bins, patches = plt.hist(x, num_bins, normed=1, facecolor=col, alpha=0.01)
y = mlab.normpdf(bins, mu, sigma)
plt.plot(bins, y, line)
plt.show()
Obtuve una ventana con la pantalla pero con muchas posibilidades de exportación, como el jpeg a continuación.
Estoy seguro de que puedes mejorar mi código, etc.
Todas las herramientas mencionadas y utilizadas son:
dwjohnston