I am attempting to plot 7 subplots (there are 7 categories the data is sorted into) with multiple data sets. My function currently works for one set of data and I have attempted to iterate over args*. When I do this it appears that both sets of data are not being added. How can I iterate over each arg/dictionary (data set values) and dump them into each of the 7 plots with different colors?
def plot_histo(*args,num_bins):
#print(dic_data)
fig = plt.figure()
fig, axes = plt.subplots(2, 4, figsize=(14,6))
axes = axes.ravel()
for arg in args:
for i, (key, value) in enumerate(arg.items()):
#print(i, key, value)
axes[i].hist(value,num_bins,stacked= True, alpha=0.5)
axes[i].set(title=key.upper(), xlabel='R-Resistance',ylabel='N')
#axes[i].legend()
plt.tight_layout()
plt.savefig('wafer_probe_results.png')
plt.show()
p_histo = plot_histo(w21_results,w22_results,num_bins=10)
Note the args are dictionaries where I only care about the value. The code for a single set of data is as follows.
def plot_histo(dic_data,num_bins):
#print(dic_data)
fig = plt.figure()
fig, axes = plt.subplots(2, 4, figsize=(14,6))
axes = axes.ravel()
for i, (key, value) in enumerate(dic_data.items()):
#print(i, key, value)
axes[i].hist(value,num_bins,stacked= True, alpha=0.5)
axes[i].set(title=key.upper(), xlabel='R-Resistance',ylabel='N')
#axes[i].legend()
plt.tight_layout()
plt.savefig('wafer_probe_results.png')
plt.show()
p_histo = plot_histo(w21_results,num_bins=10)
Where dic_data is the dictionary:
dic_data ={'CPW': array([4.2, 4.1, 4.3, 4.3, 4.2, 4.3, 4.1, 4.2, 4.2, 4.1, 4.2, 4.2, 4. ,
4.1, 4.3, 4.1, 4.1, 4.4, 4.1, 4.2, 4.3, 4.1, 4.1, 4.1, 4.2, 4.2,
4.4, 4.2]),'CPW to Ground': array([33333., 99960., 99900., 33323., 99950., 99900., 99990., 99950.,
99890., 99990., 99930., 99900., 99990., 99930., 99890., 49980.,
99940., 99890., 99960., 99930., 99890., 99910., 99910., 99900.,
99910., 99900., 99890., 99890.]),etc...}
I am really close, any help or tips are appreciated.
Edit/Update:
#function plots histograms
def plot_histo(*args,num_bins):
#print(args)
datasets = (args)
#print(datasets)
fig = plt.figure()
fig, axes = plt.subplots(2, 4, figsize=(14,6))
axes = axes.ravel()
categories = args[0].keys()
for axes,key in zip(axes,categories):
values = [dictionary[key] for dictionary in args]
axes.hist(values, num_bins, label=names)
plt.tight_layout()
p_histo = plot_histo(w21_results,w22_results,w24_results,w23_results,num_bins=10)
plt.savefig('wafer_probe_results.png')
plt.show()
p_histo = plot_histo(w21_results,w22_results,w24_results,w23_results,num_bins=10)
plt.savefig('wafer_probe_results.png')
plt.show()
gives the correct amount of graphs, correct amount of lines, but is not reading or storing the data right