Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 10 years ago

Geremia gravatar image

[code]import matplotlib as mpl 
import matplotlib.pyplot as plt

px,py = x,y#x,y

nx = ny = 100 #number of bins in x,y directions x_bins = np.linspace(px.min(), px.max(), nx+1) y_bins = np.linspace(py.min(), py.max(), ny+1)

plt.xlabel('Nonce'); plt.ylabel('Hash (log10)'); plt.title(r'2-D Histogram of First '+str(len(x))+' Valid Nonces and Hashes');

plt.hist2d(px, py, [x_bins,y_bins], norm=mpl.colors.LogNorm());

plt.savefig('Density Plot (log colorscale).png') plt.close();[/code]

click to hide/show revision 2
No.2 Revision

[code]import

import matplotlib as mpl
import import matplotlib.pyplot as plt

plt

px,py = x,y#x,y

x,y

nx = ny = 100 #number of bins in x,y directions x_bins = np.linspace(px.min(), px.max(), nx+1) y_bins = np.linspace(py.min(), py.max(), ny+1)

ny+1)

plt.xlabel('Nonce'); plt.ylabel('Hash ($\log_{10}$)'); plt.title(r'2-D Histogram of First '+str(len(x))+' Valid Nonces and Hashes');

Hashes');

plt.hist2d(px, py, [x_bins,y_bins], norm=mpl.colors.LogNorm());

norm=mpl.colors.LogNorm());

plt.savefig('Density Plot (log colorscale).png') plt.close();[/code]plt.close();

This produces a nice plot: hist2d plot

click to hide/show revision 3
No.3 Revision

They key is to use hist2d:

import matplotlib as mpl
import matplotlib.pyplot as plt

px,py = x,y

nx = ny = 100 #number of bins in x,y directions
x_bins = np.linspace(px.min(), px.max(), nx+1)
y_bins = np.linspace(py.min(), py.max(), ny+1)

plt.xlabel('Nonce');
plt.ylabel('Hash ($\log_{10}$)');
plt.title(r'2-D Histogram of First '+str(len(x))+' Valid Nonces and Hashes');

plt.hist2d(px, py, [x_bins,y_bins], norm=mpl.colors.LogNorm());

plt.savefig('Density Plot (log colorscale).png')
plt.close();

This produces a nice plot: hist2d plot