Skip to content

Commit ed3e87b

Browse files
committed
Adds markers to Area Chart device.
1 parent fae2d98 commit ed3e87b

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

_changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v0.8.21
2+
- Adds markers to Area Chart device. Note that the marker will be placed
3+
at the cumulative value of the data point and not its absolute value.
4+
15
v0.8.20
26
- Adds plot min and max to Area Chart device. Note that the min/max lines
37
reflect the cumulative value of the data point and not its absolute value.

matplotlib.indigoPlugin/Contents/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>PluginVersion</key>
6-
<string>0.8.20</string>
6+
<string>0.8.21</string>
77
<key>ServerApiVersion</key>
88
<string>2.0</string>
99
<key>IwsApiVersion</key>

matplotlib.indigoPlugin/Contents/Server Plugin/plugin.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
# date range.)
5757
# TODO: When the number of bars to be plotted is less than the number of bars
5858
# requested (because there isn't enough data), the bars plot funny.
59-
# TODO: add each devices.xml section to its own template file.
6059
# TODO: do stack plots support markers? Not inherently (apparently) but you
6160
# can fool it by laying a line on top of the stack. May want to just not
6261
# support it for now...
@@ -110,7 +109,7 @@
110109
__license__ = Dave.__license__
111110
__build__ = Dave.__build__
112111
__title__ = "Matplotlib Plugin for Indigo Home Control"
113-
__version__ = "0.8.20"
112+
__version__ = "0.8.21"
114113

115114
# =============================================================================
116115

@@ -3071,10 +3070,6 @@ def __init__(self, plugin):
30713070
self.final_data = []
30723071
self.host_plugin = plugin
30733072

3074-
# TODO: Markers will need to be added through a secondary plot which uses a
3075-
# line plot (stackplots don't support markers).
3076-
# TODO: Min, Max and annotations plot on their absolute value and not the spot
3077-
# where they are.
30783073
# =============================================================================
30793074
def chart_area(self, dev, p_dict, k_dict, return_queue):
30803075
"""
@@ -3098,7 +3093,7 @@ def chart_area(self, dev, p_dict, k_dict, return_queue):
30983093
p_dict['faceColor'] = r"#{0}".format(p_dict['faceColor'].replace(' ', '').replace('#', ''))
30993094
x_obs = ''
31003095
y_obs_tuple = () # Y values
3101-
y_obs_tuple_rel = {}
3096+
y_obs_tuple_rel = {} # Y values relative to chart (cumulative value)
31023097
y_colors_tuple = () # Y area colors
31033098

31043099
ax = self.make_chart_figure(p_dict['chart_width'], p_dict['chart_height'], p_dict)
@@ -3112,7 +3107,7 @@ def chart_area(self, dev, p_dict, k_dict, return_queue):
31123107

31133108
p_dict['area{0}Color'.format(area)] = r"#{0}".format(p_dict['area{0}Color'.format(area)].replace(' ', '').replace('#', ''))
31143109

3115-
# p_dict['area{0}MarkerColor'.format(area)] = r"#{0}".format(p_dict['area{0}MarkerColor'.format(area)].replace(' ', '').replace('#', ''))
3110+
p_dict['area{0}MarkerColor'.format(area)] = r"#{0}".format(p_dict['area{0}MarkerColor'.format(area)].replace(' ', '').replace('#', ''))
31163111

31173112
# If area color is the same as the background color, alert the user.
31183113
if p_dict['area{0}Color'.format(area)] == p_dict['backgroundColor']:
@@ -3190,7 +3185,6 @@ def chart_area(self, dev, p_dict, k_dict, return_queue):
31903185

31913186
# New annotations code ends here - DaveL17 2019-06-05
31923187

3193-
log['Info'].append(u"{0}".format(y_obs_tuple_rel))
31943188
if p_dict['area{0}Annotate'.format(area)]:
31953189
for xy in zip(p_dict['x_obs{0}'.format(area)], y_obs_tuple_rel['y_obs{0}'.format(area)]):
31963190
ax.annotate(u"{0}".format(xy[1]), xy=xy, xytext=(0, 0), zorder=10, **k_dict['k_annotation'])
@@ -3278,6 +3272,12 @@ def chart_area(self, dev, p_dict, k_dict, return_queue):
32783272
if self.host_plugin.pluginPrefs.get('forceOriginLines', True):
32793273
ax.axhline(y=0, color=p_dict['spineColor'])
32803274

3275+
# ================================== Markers ==================================
3276+
# Note that stackplots don't support markers, so we need to plot a line (with
3277+
# no width) on the plot to receive the markers.
3278+
ax.plot_date(p_dict['x_obs{0}'.format(area)], y_obs_tuple_rel['y_obs{0}'.format(area)], marker=p_dict['area{0}Marker'.format(area)],
3279+
markeredgecolor=p_dict['area{0}MarkerColor'.format(area)], markerfacecolor=p_dict['area{0}MarkerColor'.format(area)], zorder=10, lw=0)
3280+
32813281
self.format_custom_line_segments(ax, p_dict, k_dict, log)
32823282
self.format_grids(p_dict, k_dict, log)
32833283
self.format_title(p_dict, k_dict, log, loc=(0.5, 0.98))

0 commit comments

Comments
 (0)