ex-3: implement variable bins in the plot

This commit is contained in:
Michele Guerini Rocco 2020-04-27 21:41:29 +00:00
parent dc845be7ef
commit fca479aa63
2 changed files with 6 additions and 1 deletions

View File

@ -100,6 +100,11 @@ int main(int argc, char **argv) {
// print histogram to stdout // print histogram to stdout
if (opts.show_hist || opts.only_hist) { if (opts.show_hist || opts.only_hist) {
fputs("\n# histogram\n", stderr); fputs("\n# histogram\n", stderr);
/* Print the bins on the first line:
* this is needed by plot.py to make a
* 2D histogram plot.
*/
fprintf(stdout, "%ld %ld\n", opts.bins_theta, opts.bins_phi);
gsl_histogram2d_fprintf(stdout, hist, "%g", "%g"); gsl_histogram2d_fprintf(stdout, hist, "%g", "%g");
} }

View File

@ -5,8 +5,8 @@ from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm from matplotlib import cm
import sys import sys
bins = tuple(map(int, sys.stdin.readline().split()))
xedges, yedges, counts = loadtxt(sys.stdin, unpack=True, usecols=[0,2,4]) xedges, yedges, counts = loadtxt(sys.stdin, unpack=True, usecols=[0,2,4])
bins = (30, 60)
counts = counts.reshape(bins) counts = counts.reshape(bins)
plt.rcParams['font.size'] = 15 plt.rcParams['font.size'] = 15