GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — inkscape_python_figures/plot_hist.py at main · otvam/inkscape_python_figures Expand file tree/ Copy pathplot_hist.pyMore file actions 71 lines (54 loc) · 1.92 KB / Copy pathplot_hist.pyFile metadata and controls71 lines (54 loc) · 1.92 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 """ Example for a Matplotlib plot with the following features: - Histogram. - Transparency. """ __author__ = "Thomas Guillod" __copyright__ = "Thomas Guillod - Dartmouth College" __license__ = "Mozilla Public License Version 2.0" import os import numpy as np import matplotlib.pyplot as plt import utils_mpl # ########################################################### # Plot global parameters and define dummy data # ########################################################### # set global parameters utils_mpl.set_global() # create the output folder os.makedirs("render", exist_ok=True) # define dummy data x = np.random.rayleigh(size=500) y = np.random.normal(size=500) # get the axis ticks xticks = np.linspace(-2.0, +3.0, 6) yticks = np.linspace(0.0, 150.0, 6) # ########################################################### # Definition of the line plot # ########################################################### # create a figure with a determined size (fig, ax) = utils_mpl.get_fig(size=(3.5, 3.0), dpi=200) # add the histograms ax.hist(x, color="r", label="x-data", alpha=0.5) ax.hist(y, color="g", label="y-data", alpha=0.5) # set the x-axis limit and format utils_mpl.set_x_axis(ax, bnd=xticks, margin=0.05, log=False) utils_mpl.set_format(ax.xaxis, ticks=xticks, fmt="${x:+.1f}$") # set the y-axis limit and format utils_mpl.set_y_axis(ax, bnd=yticks, margin=0.0, log=False) utils_mpl.set_format(ax.yaxis, ticks=yticks, fmt="${x:.0f}$") # set the legend and labels ax.set_axisbelow(True) ax.legend(loc="upper right") ax.set_xlabel("x-axis (unit)") ax.set_ylabel("y-axis (unit)") ax.set_title("Plot Title") # set the grid utils_mpl.set_grid(fig, ax, major=True, minor=False) # save the plot for Inkscape utils_mpl.save_svg(fig, "render/hist.svg") # ########################################################### # Show the plots # ########################################################### # show the plot for inspection plt.show() |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |