mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
Cleaned up script to generate plots a little more
This commit is contained in:
parent
e23459887f
commit
32bfe3a0cd
1 changed files with 62 additions and 64 deletions
|
@ -21,7 +21,7 @@
|
|||
"# FOR NOTEBOOK USE #\n",
|
||||
"# SET DIRECTORY HERE #\n",
|
||||
"# #\n",
|
||||
"rootdir = \"varying_rate\"\n",
|
||||
"rootdir = \"varying_sample_size\"\n",
|
||||
"# #\n",
|
||||
"#############################\n",
|
||||
"\n",
|
||||
|
@ -41,12 +41,8 @@
|
|||
"import json\n",
|
||||
"from sys import exit\n",
|
||||
"\n",
|
||||
"#try:\n",
|
||||
"with open(\"{}/settings.json\".format(rootdir)) as json_file:\n",
|
||||
" settings = json.load(json_file)\n",
|
||||
"#except:\n",
|
||||
"# print(\"Please define a correct JSON file!\")\n",
|
||||
"# exit()\n",
|
||||
"\n",
|
||||
"print(\"Succesfully loaded JSON file\")"
|
||||
]
|
||||
|
@ -349,7 +345,7 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"if settings['median_plot']['enabled'] and settings['3d_plot']['enabled']:\n",
|
||||
"if settings['median_plot']['enabled'] or settings['3d_plot']['enabled']:\n",
|
||||
" medians = []\n",
|
||||
" upper_limit = []\n",
|
||||
" lower_limit = []\n",
|
||||
|
@ -606,7 +602,7 @@
|
|||
" # CREATE HISTOGRAM LEGEND #########\n",
|
||||
" ###################################\n",
|
||||
" # create a second figure for the legend\n",
|
||||
" figLegend = pylab.figure(figsize = (settings['histograms']['dimensions']['legend'][0], settings['histograms']['dimensions']['legend'][1]))\n",
|
||||
" figLegend = pylab.figure(figsize = settings['histograms']['dimensions']['legend'])\n",
|
||||
"\n",
|
||||
" # produce a legend for the objects in the other figure\n",
|
||||
" pylab.figlegend(*ax.get_legend_handles_labels(), loc = 'upper left',\n",
|
||||
|
@ -665,7 +661,7 @@
|
|||
" fig_median.savefig('{}/median_graph.pdf'.format(rootdir), dpi=600, format='pdf', bbox_inches='tight')\n",
|
||||
"\n",
|
||||
" # create a second figure for the legend\n",
|
||||
" figLegend = pylab.figure(figsize = (settings['median_plot']['dimensions']['legend'][0], settings['median_plot']['dimensions']['legend'][1]))\n",
|
||||
" figLegend = pylab.figure(figsize = settings['median_plot']['dimensions']['legend'])\n",
|
||||
"\n",
|
||||
" # produce a legend for the objects in the other figure\n",
|
||||
" pylab.figlegend(*ax_median.get_legend_handles_labels(), loc = 'upper left',\n",
|
||||
|
@ -690,80 +686,82 @@
|
|||
"outputs": [],
|
||||
"source": [
|
||||
"if settings['3d_plot']['enabled']:\n",
|
||||
" fig_3d = plt.figure(num=None, figsize=(16, 7), dpi=90, facecolor='w', edgecolor='k')\n",
|
||||
" ax_3d = fig_3d.gca(projection='3d')\n",
|
||||
" for i, subdir in enumerate(subdirs):\n",
|
||||
" fig_3d = plt.figure(num=None, figsize=(16, 7), dpi=90, facecolor='w', edgecolor='k')\n",
|
||||
" ax_3d = fig_3d.gca(projection='3d')\n",
|
||||
"\n",
|
||||
" # Make data.\n",
|
||||
" X = np.array([])\n",
|
||||
" for k in range(0, len(settings['3d_plot']['ticks']['x'])):\n",
|
||||
" X = np.append(X, k)\n",
|
||||
" # Make data.\n",
|
||||
" X = np.array([])\n",
|
||||
" for k in range(0, len(settings['3d_plot']['ticks']['x'])):\n",
|
||||
" X = np.append(X, k)\n",
|
||||
"\n",
|
||||
" Y = np.array([])\n",
|
||||
" for k in range(0, len(settings['3d_plot']['ticks']['y'])):\n",
|
||||
" Y = np.append(Y, k)\n",
|
||||
" Y = np.array([])\n",
|
||||
" for k in range(0, len(settings['3d_plot']['ticks']['y'])):\n",
|
||||
" Y = np.append(Y, k)\n",
|
||||
"\n",
|
||||
" X, Y = np.meshgrid(X, Y)\n",
|
||||
" X, Y = np.meshgrid(X, Y)\n",
|
||||
"\n",
|
||||
" Z = np.array([])\n",
|
||||
" for k in range(0, len(settings['3d_plot']['ticks']['y'])):\n",
|
||||
" for l in range(0, len(settings['3d_plot']['ticks']['x'])):\n",
|
||||
" Z = np.append(Z, medians[0][k * len(settings['3d_plot']['ticks']['x']) + l])\n",
|
||||
" Z = np.array([])\n",
|
||||
" for k in range(0, len(settings['3d_plot']['ticks']['y'])):\n",
|
||||
" for l in range(0, len(settings['3d_plot']['ticks']['x'])):\n",
|
||||
" Z = np.append(Z, medians[i][k * len(settings['3d_plot']['ticks']['x']) + l])\n",
|
||||
"\n",
|
||||
" Z = np.split(Z, len(settings['3d_plot']['ticks']['y']))\n",
|
||||
" Z = np.split(Z, len(settings['3d_plot']['ticks']['y']))\n",
|
||||
"\n",
|
||||
" # Plot the surface.\n",
|
||||
" surf = ax_3d.plot_surface(X, Y, Z, cmap=cm.Blues, linewidth=135,\n",
|
||||
" antialiased=False, shade=True)\n",
|
||||
" ax_3d.plot_wireframe(X, Y, Z, 10, lw=1, colors=\"k\", linestyles=\"solid\")\n",
|
||||
" # Plot the surface.\n",
|
||||
" surf = ax_3d.plot_surface(X, Y, Z, cmap=cm.Blues, linewidth=135,\n",
|
||||
" antialiased=False, shade=True)\n",
|
||||
" ax_3d.plot_wireframe(X, Y, Z, 10, lw=1, colors=\"k\", linestyles=\"solid\")\n",
|
||||
"\n",
|
||||
" # Customize the z axis.\n",
|
||||
" ax_3d.set_zlim(0, np.max(np.ceil(Z)))\n",
|
||||
" ax_3d.zaxis.set_major_locator(LinearLocator(10))\n",
|
||||
" # Customize the z axis.\n",
|
||||
" ax_3d.set_zlim(0, np.max(np.ceil(Z)))\n",
|
||||
" ax_3d.zaxis.set_major_locator(LinearLocator(10))\n",
|
||||
"\n",
|
||||
" ax_3d.set_xlabel(settings['3d_plot']['axis_labels']['x'], fontsize=11, family='monospace', labelpad=14)\n",
|
||||
" ax_3d.set_ylabel(settings['3d_plot']['axis_labels']['y'], fontsize=11, family='monospace', labelpad=8)\n",
|
||||
" ax_3d.set_zlabel(settings['3d_plot']['axis_labels']['z'], fontsize=11, family='monospace', labelpad=8)\n",
|
||||
" ax_3d.set_xlabel(settings['3d_plot']['axis_labels']['x'], fontsize=11, family='monospace', labelpad=14)\n",
|
||||
" ax_3d.set_ylabel(settings['3d_plot']['axis_labels']['y'], fontsize=11, family='monospace', labelpad=8)\n",
|
||||
" ax_3d.set_zlabel(settings['3d_plot']['axis_labels']['z'], fontsize=11, family='monospace', labelpad=8)\n",
|
||||
"\n",
|
||||
" ax_3d.set_xticks(np.arange(0, len(settings['3d_plot']['ticks']['x']), 1))\n",
|
||||
" ax_3d.set_xticklabels(settings['3d_plot']['ticks']['x'])\n",
|
||||
" ax_3d.set_xticks(np.arange(0, len(settings['3d_plot']['ticks']['x']), 1))\n",
|
||||
" ax_3d.set_xticklabels(settings['3d_plot']['ticks']['x'])\n",
|
||||
"\n",
|
||||
" ax_3d.set_yticklabels(settings['3d_plot']['ticks']['y'])\n",
|
||||
" ax_3d.set_zticks(np.arange(0, len(settings['3d_plot']['ticks']['z']), 1))\n",
|
||||
" ax_3d.set_yticklabels(settings['3d_plot']['ticks']['y'])\n",
|
||||
" ax_3d.set_zticks(np.arange(0, len(settings['3d_plot']['ticks']['z']), 1))\n",
|
||||
"\n",
|
||||
" x = np.argmin(Z) % (len(settings['3d_plot']['ticks']['x']) + 1)\n",
|
||||
" y = np.argmin(Z) % (len(settings['3d_plot']['ticks']['y']) + 1)\n",
|
||||
" z = np.min(Z)\n",
|
||||
" ax_3d.plot([x,x],[y,y],z, marker='v', color = 'green', markersize=11, label=\"Minimum: \"+str(z)+ \" µs\")\n",
|
||||
" x = np.argmin(Z) % (len(settings['3d_plot']['ticks']['x']))\n",
|
||||
" y = np.floor(np.argmin(Z) / (len(settings['3d_plot']['ticks']['y'])))\n",
|
||||
" z = np.min(Z)\n",
|
||||
" \n",
|
||||
" ax_3d.plot([x,x],[y,y],z, marker='v', color = 'green', markersize=15, label=\"Minimum: \"+str(z)+ \" µs\")\n",
|
||||
"\n",
|
||||
" x = np.argmax(Z) % (len(settings['3d_plot']['ticks']['x']) + 1)\n",
|
||||
" y = np.argmax(Z) % (len(settings['3d_plot']['ticks']['y']) + 1)\n",
|
||||
" z = np.max(Z)\n",
|
||||
" ax_3d.plot([x,x],[y,y],z, marker='^', color = 'red', markersize=11, label=\"Maximum: \"+str(z)+ \" µs\")\n",
|
||||
" x = np.argmax(Z) % (len(settings['3d_plot']['ticks']['x']))\n",
|
||||
" y = np.floor(np.argmax(Z) / (len(settings['3d_plot']['ticks']['y'])))\n",
|
||||
" z = np.max(Z)\n",
|
||||
" \n",
|
||||
" ax_3d.plot([x,x],[y,y],z, marker='^', color = 'red', markersize=15, label=\"Maximum: \"+str(z)+ \" µs\")\n",
|
||||
"\n",
|
||||
" norm = mpl.colors.Normalize(vmin=np.min(Z), vmax=np.max(Z))\n",
|
||||
" cb = fig_3d.colorbar(surf, shrink=0.8, aspect=10, fraction=0.1, norm=norm)\n",
|
||||
" cb.set_label(settings['3d_plot']['axis_labels']['z'], fontsize=11, family='monospace', labelpad=8)\n",
|
||||
" plt.tight_layout()\n",
|
||||
" plt.show()\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" norm = mpl.colors.Normalize(vmin=np.min(Z), vmax=np.max(Z))\n",
|
||||
" cb = fig_3d.colorbar(surf, shrink=0.8, aspect=10, fraction=0.1, norm=norm)\n",
|
||||
" cb.set_label(settings['3d_plot']['axis_labels']['z'], fontsize=11, family='monospace', labelpad=8)\n",
|
||||
" plt.tight_layout()\n",
|
||||
" plt.show()\n",
|
||||
" fig_3d.savefig('{}/median_3d_graph_{}.pdf'.format(rootdir, settings_array[i][0][2]), dpi=600, format='pdf')\n",
|
||||
"\n",
|
||||
" # create a second figure for the legend\n",
|
||||
" figLegend = pylab.figure(figsize = settings['3d_plot']['dimensions']['legend'])\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" fig_3d.savefig('{}/median_3d_graph.pdf'.format(rootdir), dpi=600, format='pdf')\n",
|
||||
"\n",
|
||||
" # create a second figure for the legend\n",
|
||||
" figLegend = pylab.figure(figsize = (settings['3d_plot']['dimensions']['legend'][0], settings['3d_plot']['dimensions']['legend'][1]))\n",
|
||||
" # The markers are too big, so lets create smaller markers\n",
|
||||
" ax_custom = figLegend.add_subplot(111)\n",
|
||||
" ax_custom.plot(0,0, marker='v', color = 'green', label=\"$\\\\tilde{t}_{min}^{max}$: \"+str(np.min(Z))+ \" µs\", markersize=8, linestyle = 'None')\n",
|
||||
" ax_custom.plot(0,0, marker='^', color = 'red', label=\"$\\\\tilde{t}_{lat}^{max}$: \"+str(np.max(Z))+ \" µs\", markersize=8, linestyle = 'None')\n",
|
||||
" ax_custom.set_visible(False)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" # The markers are too big, so lets create smaller markers\n",
|
||||
" ax_custom = figLegend.add_subplot(111)\n",
|
||||
" ax_custom.plot(0,0, marker='v', color = 'green', label=\"Minimum: \"+str(np.min(Z))+ \" µs\")\n",
|
||||
" ax_custom.plot(0,0, marker='^', color = 'red', label=\"Maximum: \"+str(np.max(Z))+ \" µs\")\n",
|
||||
" ax_custom.set_visible(False)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" pylab.figlegend(*ax_custom.get_legend_handles_labels(), loc = 'upper left',\n",
|
||||
" prop={'family':'monospace', 'size':'8'}, ncol=settings['3d_plot']['legend_columns'])\n",
|
||||
" figLegend.savefig(\"{}/legend_median_3d_plot.pdf\".format(rootdir), format='pdf')"
|
||||
" pylab.figlegend(*ax_custom.get_legend_handles_labels(), loc = 'upper left',\n",
|
||||
" prop={'family':'monospace', 'size':'8'}, ncol=settings['3d_plot']['legend_columns'])\n",
|
||||
" figLegend.savefig(\"{}/legend_median_3d_plot_{}.pdf\".format(rootdir, settings_array[i][0][2]), format='pdf')"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue