From 6315084f58cfb5e7062d0f6258d532ea13330492 Mon Sep 17 00:00:00 2001 From: Jose Luis Cercos Pita Date: Wed, 20 Jan 2016 12:36:05 +0100 Subject: [PATCH] Slightly improved the capacity curve plot --- src/Mod/Ship/shipCapacityCurve/PlotAux.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Mod/Ship/shipCapacityCurve/PlotAux.py b/src/Mod/Ship/shipCapacityCurve/PlotAux.py index 81e0595b8..12d02b00a 100644 --- a/src/Mod/Ship/shipCapacityCurve/PlotAux.py +++ b/src/Mod/Ship/shipCapacityCurve/PlotAux.py @@ -27,6 +27,8 @@ import FreeCAD import FreeCADGui from FreeCAD import Base import Spreadsheet +import matplotlib.ticker as mtick + class Plot(object): def __init__(self, l, z, v, tank): @@ -64,12 +66,17 @@ class Plot(object): vols.line.set_linestyle('-') vols.line.set_linewidth(2.0) vols.line.set_color((0.0, 0.0, 0.0)) - Plot.xlabel(r'Percentage of filling level') + Plot.xlabel(r'$\mathrm{level}$') Plot.ylabel(r'$V \; [\mathrm{m}^3]$') plt.axes.xaxis.label.set_fontsize(20) plt.axes.yaxis.label.set_fontsize(20) Plot.grid(True) + # Special percentage formatter for the x axis + fmt = '%.0f%%' + xticks = mtick.FormatStrFormatter(fmt) + plt.axes.xaxis.set_major_formatter(xticks) + # Now duplicate the axes ax = Plot.addNewAxes() # Y axis can be placed at right @@ -86,7 +93,7 @@ class Plot(object): ax.xaxis.set_label_position('top') # Plot the volume as a function of the level z coordinate - vols = Plot.plot(z, v, 'Capacity') + vols = Plot.plot(z, v, 'level') vols.line.set_linestyle('-') vols.line.set_linewidth(2.0) vols.line.set_color((0.0, 0.0, 1.0))