def make_psychrochart(svg_image, altitude, pressure_kpa, points, connectors, arrows): """Create the PsychroChart SVG file and save it to disk.""" from psychrochart.agg import PsychroChart from psychrochart.util import load_config # Load chart style: chart_style = load_config(CHART_STYLE_JSON) if altitude is not None: chart_style['limits']['altitude_m'] = altitude elif pressure_kpa is None: chart_style['limits']['pressure_kpa'] = pressure_kpa # Make chart chart = PsychroChart(chart_style, OVERLAY_ZONES_JSON, logger=_LOGGER) # Append lines t_min, t_opt, t_max = 16, 23, 30 chart.plot_vertical_dry_bulb_temp_line(t_min, { "color": [0.0, 0.125, 0.376], "lw": 2, "ls": ':' }, ' TOO COLD, {:g}°C'.format(t_min), ha='left', loc=0., fontsize=14) chart.plot_vertical_dry_bulb_temp_line(t_opt, { "color": [0.475, 0.612, 0.075], "lw": 2, "ls": ':' }) chart.plot_vertical_dry_bulb_temp_line(t_max, { "color": [1.0, 0.0, 0.247], "lw": 2, "ls": ':' }, 'TOO HOT, {:g}°C '.format(t_max), ha='right', loc=1, reverse=True, fontsize=14) chart.plot_points_dbt_rh(points, connectors) if arrows: chart.plot_arrows_dbt_rh(arrows) chart.plot_legend(frameon=False, fontsize=8, labelspacing=.8, markerscale=.7) chart.save(svg_image, format='svg') return True
def _make_chart(path_save=None): chart = PsychroChart("minimal") # Zones: zones_conf = { "zones": [ { "zone_type": "dbt-rh", "style": {"edgecolor": [1.0, 0.749, 0.0, 0.8], "facecolor": [1.0, 0.749, 0.0, 0.2], "linewidth": 2, "linestyle": "--"}, "points_x": [23, 28], "points_y": [40, 60], "label": "Summer" }, { "zone_type": "dbt-rh", "style": {"edgecolor": [0.498, 0.624, 0.8], "facecolor": [0.498, 0.624, 1.0, 0.2], "linewidth": 2, "linestyle": "--"}, "points_x": [18, 23], "points_y": [35, 55], "label": "Winter" } ] } chart.append_zones(zones_conf) # Plotting chart.plot() # Vertical lines t_min, t_opt, t_max = 16, 23, 30 chart.plot_vertical_dry_bulb_temp_line( t_min, {"color": [0.0, 0.125, 0.376], "lw": 2, "ls": ':'}, ' TOO COLD ({}°C)'.format(t_min), ha='left', loc=0., fontsize=14) chart.plot_vertical_dry_bulb_temp_line( t_opt, {"color": [0.475, 0.612, 0.075], "lw": 2, "ls": ':'}) chart.plot_vertical_dry_bulb_temp_line( t_max, {"color": [1.0, 0.0, 0.247], "lw": 2, "ls": ':'}, 'TOO HOT ({}°C) '.format(t_max), ha='right', loc=1, reverse=True, fontsize=14) # Save to disk the base chart if path_save is not None: path_svg = os.path.join( basedir, path_save) chart.save(path_svg) return chart
def _make_chart(): chart = PsychroChart("minimal") # Zones: zones_conf = { "zones": [ { "zone_type": "dbt-rh", "style": {"edgecolor": [1.0, 0.749, 0.0, 0.8], "facecolor": [1.0, 0.749, 0.0, 0.2], "linewidth": 2, "linestyle": "--"}, "points_x": [23, 28], "points_y": [40, 60], "label": "Summer" }, { "zone_type": "dbt-rh", "style": {"edgecolor": [0.498, 0.624, 0.8], "facecolor": [0.498, 0.624, 1.0, 0.2], "linewidth": 2, "linestyle": "--"}, "points_x": [18, 23], "points_y": [35, 55], "label": "Winter" } ] } chart.append_zones(zones_conf) # Plotting chart.plot() # Vertical lines t_min, t_opt, t_max = 16, 23, 30 chart.plot_vertical_dry_bulb_temp_line( t_min, {"color": [0.0, 0.125, 0.376], "lw": 2, "ls": ':'}, ' TOO COLD ({}°C)'.format(t_min), ha='left', loc=0., fontsize=14) chart.plot_vertical_dry_bulb_temp_line( t_opt, {"color": [0.475, 0.612, 0.075], "lw": 2, "ls": ':'}) chart.plot_vertical_dry_bulb_temp_line( t_max, {"color": [1.0, 0.0, 0.247], "lw": 2, "ls": ':'}, 'TOO HOT ({}°C) '.format(t_max), ha='right', loc=1, reverse=True, fontsize=14) points = {'exterior': {'label': 'Exterior', 'style': { 'color': [0.855, 0.004, 0.278, 0.8], 'marker': 'X', 'markersize': 15}, 'xy': (31.06, 32.9)}, 'exterior_estimated': { 'label': 'Estimated (Weather service)', 'style': {'color': [0.573, 0.106, 0.318, 0.5], 'marker': 'x', 'markersize': 10}, 'xy': (36.7, 25.0)}, 'interior': {'label': 'Interior', 'style': { 'color': [0.592, 0.745, 0.051, 0.9], 'marker': 'o', 'markersize': 30}, 'xy': (29.42, 52.34)}} connectors = [{'start': 'exterior', 'end': 'exterior_estimated', 'style': {'color': [0.573, 0.106, 0.318, 0.7], "linewidth": 2, "linestyle": "-."}}, {'start': 'exterior', 'end': 'interior', 'style': {'color': [0.855, 0.145, 0.114, 0.8], "linewidth": 2, "linestyle": ":"}}] points_plot = chart.plot_points_dbt_rh(points, connectors) print('Points in chart: %s' % points_plot) # Legend chart.plot_legend( markerscale=.7, frameon=False, fontsize=10, labelspacing=1.2) # Save to disk path_svg = os.path.join( basedir, 'chart_overlay_style_minimal.svg') chart.save(path_svg)
def _make_chart(): chart = PsychroChart("minimal") # Zones: zones_conf = { "zones": [ { "zone_type": "dbt-rh", "style": { "edgecolor": [1.0, 0.749, 0.0, 0.8], "facecolor": [1.0, 0.749, 0.0, 0.2], "linewidth": 2, "linestyle": "--", }, "points_x": [23, 28], "points_y": [40, 60], "label": "Summer", }, { "zone_type": "dbt-rh", "style": { "edgecolor": [0.498, 0.624, 0.8], "facecolor": [0.498, 0.624, 1.0, 0.2], "linewidth": 2, "linestyle": "--", }, "points_x": [18, 23], "points_y": [35, 55], "label": "Winter", }, ] } chart.append_zones(zones_conf) # Plotting chart.plot() # Vertical lines t_min, t_opt, t_max = 16, 23, 30 chart.plot_vertical_dry_bulb_temp_line( t_min, { "color": [0.0, 0.125, 0.376], "lw": 2, "ls": ":" }, f" TOO COLD ({t_min}°C)", ha="left", loc=0.0, fontsize=14, ) chart.plot_vertical_dry_bulb_temp_line( t_opt, { "color": [0.475, 0.612, 0.075], "lw": 2, "ls": ":" }) chart.plot_vertical_dry_bulb_temp_line( t_max, { "color": [1.0, 0.0, 0.247], "lw": 2, "ls": ":" }, f"TOO HOT ({t_max}°C) ", ha="right", loc=1, reverse=True, fontsize=14, ) points = { "exterior": { "label": "Exterior", "style": { "color": [0.855, 0.004, 0.278, 0.8], "marker": "X", "markersize": 15, }, "xy": (31.06, 32.9), }, "exterior_estimated": { "label": "Estimated (Weather service)", "style": { "color": [0.573, 0.106, 0.318, 0.5], "marker": "x", "markersize": 10, }, "xy": (36.7, 25.0), }, "interior": { "label": "Interior", "style": { "color": [0.592, 0.745, 0.051, 0.9], "marker": "o", "markersize": 30, }, "xy": (29.42, 52.34), }, } connectors = [ { "start": "exterior", "end": "exterior_estimated", "style": { "color": [0.573, 0.106, 0.318, 0.7], "linewidth": 2, "linestyle": "-.", }, }, { "start": "exterior", "end": "interior", "style": { "color": [0.855, 0.145, 0.114, 0.8], "linewidth": 2, "linestyle": ":", }, }, ] chart.plot_points_dbt_rh(points, connectors) # Legend chart.plot_legend(markerscale=0.7, frameon=False, fontsize=10, labelspacing=1.2) # Save to disk path_svg = TEST_BASEDIR / "chart_overlay_style_minimal.svg" chart.save(path_svg)
def _make_chart(path_save=None): chart = PsychroChart("minimal") # Zones: zones_conf = { "zones": [ { "zone_type": "dbt-rh", "style": { "edgecolor": [1.0, 0.749, 0.0, 0.8], "facecolor": [1.0, 0.749, 0.0, 0.2], "linewidth": 2, "linestyle": "--", }, "points_x": [23, 28], "points_y": [40, 60], "label": "Summer", }, { "zone_type": "dbt-rh", "style": { "edgecolor": [0.498, 0.624, 0.8], "facecolor": [0.498, 0.624, 1.0, 0.2], "linewidth": 2, "linestyle": "--", }, "points_x": [18, 23], "points_y": [35, 55], "label": "Winter", }, ] } chart.append_zones(zones_conf) # Plotting chart.plot() # Vertical lines t_min, t_opt, t_max = 16, 23, 30 chart.plot_vertical_dry_bulb_temp_line( t_min, { "color": [0.0, 0.125, 0.376], "lw": 2, "ls": ":" }, f" TOO COLD ({t_min}°C)", ha="left", loc=0.0, fontsize=14, ) chart.plot_vertical_dry_bulb_temp_line(t_opt, { "color": [0.475, 0.612, 0.075], "lw": 2, "ls": ":" }) chart.plot_vertical_dry_bulb_temp_line( t_max, { "color": [1.0, 0.0, 0.247], "lw": 2, "ls": ":" }, f"TOO HOT ({t_max}°C) ", ha="right", loc=1, reverse=True, fontsize=14, ) # Save to disk the base chart if path_save is not None: path_svg = TEST_BASEDIR / path_save chart.save(path_svg) return chart