Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

[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 ($\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();[/code]

[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

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