Skip to content

Commit

Permalink
fix issues with new versions of pandas and matplotlib (#117)
Browse files Browse the repository at this point in the history
* fix issues with new versions of pandas and matplotlib

* support MIN as a key
  • Loading branch information
samuelduchesne authored Jun 12, 2024
1 parent a9cbbb8 commit 7080ad2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions energy_pandas/energypandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ def plot3d(
y = z.index.values

x, y = meshgrid(x, y)
# Remove edgecolors from kwargs
kwargs.pop("edgecolors", None)
ax.contour3D(x, y, z.values, 150, cmap=cmap, **kwargs)
else:
raise NameError('plot kind "{}" is not supported'.format(kind))
Expand Down Expand Up @@ -767,16 +769,16 @@ def plot2d(

offset_n = f"{offset.n}-" if offset.n > 1 else ""
ylabel = (
f"{offset_n}{RESOLUTION_NAME[offset.name]} of "
f"{RESOLUTION_NAME[yperiod.resolution_string][0:-1]}"
f"{offset_n}{RESOLUTION_NAME[str(offset.name).upper()]} of "
f"{RESOLUTION_NAME[yperiod.resolution_string.upper()][0:-1]}"
)

stacked, timeindex = tsam.unstackToPeriods(
copy.deepcopy(self), int(periodlength)
)
if xlabel is None:
xperiod = (periodlength * offset).delta
xlabel = f"{RESOLUTION_NAME[xperiod.resolution_string]}"
xlabel = f"{RESOLUTION_NAME[xperiod.resolution_string.upper()]}"
cmap = plt.get_cmap(cmap)
if vcenter is not None:
norm = TwoSlopeNorm(vcenter, vmin=vmin, vmax=vmax)
Expand Down Expand Up @@ -820,6 +822,7 @@ def plot2d(
D="Days",
H="Hours",
T="Minutes",
MIN="Minutes",
S="Seconds",
L="Milliseconds",
U="Microseconds",
Expand Down
4 changes: 2 additions & 2 deletions energy_pandas/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ def _plot_surface(ax, x, y, z, cmap=None, **kwargs):
**kwargs:
"""
if cmap is None:
cmap = cm.gist_earth
cmap = plt.get_cmap("gist_earth")

ls = LightSource(270, 45)
# To use a custom hillshading mode, override the built-in shading and pass
# in the rgb colors of the shaded surface calculated from "shade".
rgb = ls.shade(z, cmap=cm.get_cmap(cmap), vert_exag=0.1, blend_mode="soft")
rgb = ls.shade(z, cmap=plt.get_cmap(cmap), vert_exag=0.1, blend_mode="soft")
surf = ax.plot_surface(
x,
y,
Expand Down

0 comments on commit 7080ad2

Please sign in to comment.