matplotlib

Table Of Contents

This Page

Plots Package

Plots Package

Plots Module

CoolProp.Plots.Plots.InlineLabel(xv, yv, x=None, y=None, axis=None, fig=None)

This will give the coordinates and rotation required to align a label with a line on a plot

class CoolProp.Plots.Plots.IsoLine

Bases: object

class CoolProp.Plots.Plots.IsoLines(fluid_ref, graph_type, iso_type, **kwargs)

Bases: CoolProp.Plots.Common.BasePlot

draw_isolines(iso_range, num=None, rounding=False, line_opts=None, axis_limits=None)

Draw lines with constant values of type ‘which’ in terms of x and y as defined by ‘plot’. ‘iMin’ and ‘iMax’ are minimum and maximum value between which ‘num’ get drawn.

There should also be helpful error messages...

get_isolines(iso_range=[], num=None, rounding=False, line_opts=None, axis_limits=None)

This is the core method to obtain lines in the dimensions defined by ‘plot’ that describe the behaviour of fluid ‘Ref’. The constant value is determined by ‘iName’ and has the values of ‘iValues’.

‘iValues’ is an array-like object holding at least one element. Lines are calculated for every entry in ‘iValues’. If the input ‘num’ is larger than the amount of entries in ‘iValues’, an internally defined pattern is used to calculate an appropriate line spacing between the maximum and minimum values provided in ‘iValues’.

Returns lines[num] - an array of dicts containing ‘x’ and ‘y’ coordinates for bubble and dew line. Additionally, the dict holds the keys ‘label’ and ‘opts’, those can be used for plotting as well.

CoolProp.Plots.Plots.PT(Ref, Tmin=None, Tmax=None, show=False, axis=None, *args, **kwargs)

Make a pressure-temperature plot for the given fluid

Note

CoolProps.Plots.PT() will be deprecated in future releases and replaced with CoolProps.Plots.PropsPlot()

Ref : str
The given reference fluid
Tmin : float, Optional
Minimum limit for the saturation line
Tmax : float, Optional
Maximum limit for the saturation line
show : bool, Optional
Show the current plot (Default: False)
axis : matplotlib.pyplot.gca(), Optional
The current axis system to be plotted to. (Default: create a new axis system)

Examples

>>> from CoolProp.Plots import PT
>>> PT('R290', show=True)
>>> from CoolProp.Plots import PT
>>> PT('R290', show=True, Tmin=200, Tmax=300)
>>> from matplotlib import pyplot
>>> fig = pyplot.figure(1)
>>> ax = fig.gca()
>>> PT('R290', show=True, axis=ax)
CoolProp.Plots.Plots.Ph(Ref, Tmin=None, Tmax=None, show=False, axis=None, *args, **kwargs)

Make a pressure-enthalpy plot for the given fluid

Note

CoolProps.Plots.Ph() will be deprecated in future releases and replaced with CoolProps.Plots.PropsPlot()

Ref : str
The given reference fluid
Tmin : float, Optional
Minimum limit for the saturation line
Tmax : float, Optional
Maximum limit for the saturation line
show : bool, Optional
Show the current plot (Default: False)
axis : matplotlib.pyplot.gca(), Optional
The current axis system to be plotted to. (Default: create a new axis system)

Examples

>>> from CoolProp.Plots import Ph
>>> Ph('R290', show=True)
>>> from CoolProp.Plots import Ph
>>> Ph('R290', show=True, Tmin=200, Tmax=300)
>>> from matplotlib import pyplot
>>> fig = pyplot.figure(1)
>>> ax = fig.gca()
>>> Ph('R290', show=True, axis=ax)
CoolProp.Plots.Plots.Prho(Ref, Tmin=None, Tmax=None, show=False, axis=None, *args, **kwargs)

Make a pressure-density plot for the given fluid

Note

CoolProps.Plots.Prho() will be deprecated in future releases and replaced with CoolProps.Plots.PropsPlot()

Ref : str
The given reference fluid
Tmin : float, Optional
Minimum limit for the saturation line
Tmax : float, Optional
Maximum limit for the saturation line
show : bool, Optional
Show the current plot (Default: False)
axis : matplotlib.pyplot.gca(), Optional
The current axis system to be plotted to. (Default: create a new axis system)

Examples

>>> from CoolProp.Plots import Prho
>>> Prho('R290', show=True)
>>> from CoolProp.Plots import Prho
>>> Prho('R290', show=True, Tmin=200, Tmax=300)
>>> from matplotlib import pyplot
>>> fig = pyplot.figure(1)
>>> ax = fig.gca()
>>> Prho('R290', show=True, axis=ax)
class CoolProp.Plots.Plots.PropsPlot(fluid_ref, graph_type, **kwargs)

Bases: CoolProp.Plots.Common.BasePlot

Create graph for the specified fluid properties

fluid_ref : str
The refence fluid
graph_type : str
The graph type to be plotted
axis : matplotlib.pyplot.gca(), Optional
The current axis system to be plotted to. Default: create a new axis system
fig : matplotlib.pyplot.figure(), Optional
The current figure to be plotted to. Default: create a new figure
plot_units : str
Unit system for for plotting (defaults to ‘kSI’), Optional
>>> from CoolProp.State import State
>>> from CoolProp.Plots import PropsPlot
>>> plt = PropsPlot('Water', 'Ph')
>>> plt.show()
>>> plt = PropsPlot('n-Pentane', 'Ts')
>>> plt.set_axis_limits([-0.5, 1.5, 300, 530])
>>> plt.draw_isolines('Q', [0.1, 0.9])
>>> plt.draw_isolines('P', [100, 2000])
>>> plt.draw_isolines('D', [2, 600])
>>> plt.show()
>>> fluid = 'Water'
>>> p_min = 20
>>> p_max = 15e3
>>> T_max = 550 + 273.15
>>> S1 = State(fluid, dict(P=p_min, Q=0))     # condenser outlet
>>> S2 = State(fluid, dict(P=p_max, S=S1.s))  # isentropic compression
>>> S3 = State(fluid, dict(P=p_max, T=T_max)) # isobaric heating
>>> S4 = State(fluid, dict(P=p_min, S=S3.s))  # isentropic expansion
>>> Ts = PropsPlot(fluid, 'Ts')
>>> Ts.draw_process([S1, S2, S3, S4, S1])
>>> Ts.show()

Note

See the online documentation for a the available fluids and graph types

draw_isolines(iso_type, iso_range, num=10, rounding=False, units='kSI', line_opts=None, axis_limits=None)

Create isolines

Parameters:
  • iso_type (str) – Type of the isolines
  • iso_range (list) – Range between isolines will be created [min, max]
  • num (int) – Number of the isolines within range, Optional
  • units (str) – Unit system of the input data (‘kSI’ or ‘SI’), Optional
  • line_opts (dict) – Line options (please see matplotlib.pyplot.plot()), Optional
  • axis_limits (list) – Limits for drawing isolines [[xmin, xmax], [ymin, ymax]], Optional
draw_process(states, line_opts={'color': 'r', 'lw': 1.5})

Draw process or cycle from list of State objects

Parameters:
  • states (list) – List of CoolProp.State.State objects
  • line_opts (dict) – Line options (please see matplotlib.pyplot.plot()), Optional
CoolProp.Plots.Plots.Ps(Ref, Tmin=None, Tmax=None, show=False, axis=None, *args, **kwargs)

Make a pressure-entropy plot for the given fluid

Note

CoolProps.Plots.Ps() will be deprecated in future releases and replaced with CoolProps.Plots.PropsPlot()

Ref : str
The given reference fluid
Tmin : float, Optional
Minimum limit for the saturation line
Tmax : float, Optional
Maximum limit for the saturation line
show : bool, Optional
Show the current plot (Default: False)
axis : matplotlib.pyplot.gca(), Optional
The current axis system to be plotted to. (Default: create a new axis system)

Examples

>>> from CoolProp.Plots import Ps
>>> Ps('R290', show=True)
>>> from CoolProp.Plots import Ps
>>> Ps('R290', show=True, Tmin=200, Tmax=300)
>>> from matplotlib import pyplot
>>> fig = pyplot.figure(1)
>>> ax = fig.gca()
>>> Ps('R290', show=True, axis=ax)
CoolProp.Plots.Plots.Trho(Ref, Tmin=None, Tmax=None, show=False, axis=None, *args, **kwargs)

Make a temperature-density plot for the given fluid

Note

CoolProps.Plots.Trho() will be deprecated in future releases and replaced with CoolProps.Plots.PropsPlot()

Ref : str
The given reference fluid
Tmin : float, Optional
Minimum limit for the saturation line
Tmax : float, Optional
Maximum limit for the saturation line
show : bool, Optional
Show the current plot (Default: False)
axis : matplotlib.pyplot.gca(), Optional
The current axis system to be plotted to. (Default: create a new axis system)

Examples

>>> from CoolProp.Plots import Trho
>>> Trho('R290', show=True)
>>> from CoolProp.Plots import Trho
>>> Trho('R290', show=True, Tmin=200, Tmax=300)
>>> from matplotlib import pyplot
>>> fig = pyplot.figure(1)
>>> ax = fig.gca()
>>> Trho('R290', show=True, axis=ax)
CoolProp.Plots.Plots.Ts(Ref, Tmin=None, Tmax=None, show=False, axis=None, *args, **kwargs)

Make a temperature-entropy plot for the given fluid

Note

CoolProps.Plots.Ts() will be deprecated in future releases and replaced with CoolProps.Plots.PropsPlot()

Ref : str
The given reference fluid
Tmin : float, Optional
Minimum limit for the saturation line
Tmax : float, Optional
Maximum limit for the saturation line
show : bool, Optional
Show the current plot (Default: False)
axis : matplotlib.pyplot.gca(), Optional
The current axis system to be plotted to. (Default: create a new axis system)

Examples

>>> from CoolProp.Plots import Ts
>>> Ts('R290', show=True)
>>> from CoolProp.Plots import Ts
>>> Ts('R290', show=True, Tmin=200, Tmax=300)
>>> from matplotlib import pyplot
>>> fig = pyplot.figure(1)
>>> ax = fig.gca()
>>> Ts('R290', show=True, axis=ax)
CoolProp.Plots.Plots.drawIsoLines(Ref, plot, which, iValues=[], num=0, show=False, axis=None, units='kSI', line_opts=None)

Draw lines with constant values of type ‘which’ in terms of x and y as defined by ‘plot’. ‘iMin’ and ‘iMax’ are minimum and maximum value between which ‘num’ get drawn.

Note

CoolProps.Plots.drawIsoLines() will be depreciated in future releases and replaced with CoolProps.Plots.IsoLines()

Ref : str
The given reference fluid
plot : str
The plot type used
which : str
The iso line type
iValues : list
The list of constant iso line values
num : int, Optional
The number of iso lines (Default: 0 - Use iValues list only)
show : bool, Optional
Show the current plot (Default: False)
axis : matplotlib.pyplot.gca(), Optional
The current axis system to be plotted to. (Default: create a new axis system)
units : str
Unit system of the input data (‘kSI’ or ‘SI’), Optional
line_opts : dict
Line options (please see matplotlib.pyplot.plot()), Optional

Examples

>>> from matplotlib import pyplot
>>> from CoolProp.Plots import Ts, drawIsoLines
>>>
>>> Ref = 'n-Pentane'
>>> ax = Ts(Ref)
>>> ax.set_xlim([-0.5, 1.5])
>>> ax.set_ylim([300, 530])
>>> quality = drawIsoLines(Ref, 'Ts', 'Q', [0.3, 0.5, 0.7, 0.8], axis=ax)
>>> isobars = drawIsoLines(Ref, 'Ts', 'P', [100, 2000], num=5, axis=ax)
>>> isochores = drawIsoLines(Ref, 'Ts', 'D', [2, 600], num=7, axis=ax)
>>> pyplot.show()
CoolProp.Plots.Plots.drawLines(Ref, lines, axis, plt_kwargs=None)

Just an internal method to systematically plot values from the generated ‘line’ dicts, method is able to cover the whole saturation curve. Closes the gap at the critical point and adds a marker between the two last points of bubble and dew line if they reach up to critical point. Returns the an array of line objects that can be used to change the colour or style afterwards.

CoolProp.Plots.Plots.hs(Ref, Tmin=None, Tmax=None, show=False, axis=None, *args, **kwargs)

Make a enthalpy-entropy plot for the given fluid

Note

CoolProps.Plots.hs() will be deprecated in future releases and replaced with CoolProps.Plots.PropsPlot()

Ref : str
The given reference fluid
Tmin : float, Optional
Minimum limit for the saturation line
Tmax : float, Optional
Maximum limit for the saturation line
show : bool, Optional
Show the current plot (Default: False)
axis : matplotlib.pyplot.gca(), Optional
The current axis system to be plotted to. (Default: create a new axis system)

Examples

>>> from CoolProp.Plots import hs
>>> hs('R290', show=True)
>>> from CoolProp.Plots import hs
>>> hs('R290', show=True, Tmin=200, Tmax=300)
>>> from matplotlib import pyplot
>>> fig = pyplot.figure(1)
>>> ax = fig.gca()
>>> hs('R290', show=True, axis=ax)

PsychChart Module

This file implements a psychrometric chart for air at 1 atm

class CoolProp.Plots.PsychChart.EnthalpyLines(H_values)

Bases: object

plot(ax)
class CoolProp.Plots.PsychChart.HumidityLabels(RH_values, h)

Bases: object

plot(ax)
class CoolProp.Plots.PsychChart.HumidityLines(RH_values)

Bases: object

plot(ax)
class CoolProp.Plots.PsychChart.PlotFormatting

Bases: object

plot(ax)
class CoolProp.Plots.PsychChart.SaturationLine

Bases: object

plot(ax)

SimpleCycles Module

CoolProp.Plots.SimpleCycles.EconomizedCycle(Ref, Qin, Te, Tc, DTsh, DTsc, eta_oi, f_p, Ti, Ts_Ph='Ts', skipPlot=False, axis=None, **kwargs)

This function plots an economized cycle, on the current axis, or that given by the optional parameter axis

Required parameters:

  • Ref : Refrigerant [string]
  • Qin : Cooling capacity [W]
  • Te : Evap Temperature [K]
  • Tc : Condensing Temperature [K]
  • DTsh : Evaporator outlet superheat [K]
  • DTsc : Condenser outlet subcooling [K]
  • eta_oi : Adiabatic efficiency of compressor (no units) in range [0,1]
  • f_p : fraction of compressor power lost as ambient heat transfer in range [0,1]
  • Ti : Saturation temperature corresponding to intermediate pressure [K]

Optional parameters:

  • Ts_Ph : ‘Ts’ for a Temperature-Entropy plot, ‘Ph’ for a Pressure-Enthalpy
  • axis : An axis to use instead of the active axis
  • skipPlot : If True, won’t actually plot anything, just print COP
CoolProp.Plots.SimpleCycles.SimpleCycle(Ref, Te, Tc, DTsh, DTsc, eta_a, Ts_Ph='Ph', skipPlot=False, axis=None)

This function plots a simple four-component cycle, on the current axis, or that given by the optional parameter axis

Required parameters:

  • Ref : A string for the refrigerant
  • Te : Evap Temperature in K
  • Tc : Condensing Temperature in K
  • DTsh : Evaporator outlet superheat in K
  • DTsc : Condenser outlet subcooling in K
  • eta_a : Adiabatic efficiency of compressor (no units) in range [0,1]

Optional parameters:

  • Ts_Ph : ‘Ts’ for a Temperature-Entropy plot, ‘Ph’ for a Pressure-Enthalpy
  • axis : An axis to use instead of the active axis
  • skipPlot : If True, won’t actually plot anything, just print COP
CoolProp.Plots.SimpleCycles.TwoStage(Ref, Q, Te, Tc, DTsh, DTsc, eta_oi, f_p, Tsat_ic, DTsh_ic, Ts_Ph='Ph', prints=False, skipPlot=False, axis=None, **kwargs)

This function plots a two-stage cycle, on the current axis, or that given by the optional parameter axis

Required parameters:

  • Ref : Refrigerant [string]
  • Q : Cooling capacity [W]
  • Te : Evap Temperature [K]
  • Tc : Condensing Temperature [K]
  • DTsh : Evaporator outlet superheat [K]
  • DTsc : Condenser outlet subcooling [K]
  • eta_oi : Adiabatic efficiency of compressor (no units) in range [0,1]
  • f_p : fraction of compressor power lost as ambient heat transfer in range [0,1]
  • Tsat_ic : Saturation temperature corresponding to intermediate pressure [K]
  • DTsh_ic : Superheating at outlet of intermediate stage [K]

Optional parameters:

  • Ts_Ph : ‘Ts’ for a Temperature-Entropy plot, ‘Ph’ for a Pressure-Enthalpy
  • prints : True to print out some values
  • axis : An axis to use instead of the active axis
  • skipPlot : If True, won’t actually plot anything, just print COP