Skip to content

Commit 270bcc3

Browse files
authored
Merge pull request #85 from jMuzsik/master
Bug fix - error when hovering pop up window For one, cb.formatter = matplotlib.ticker.FormatStrFormatter("") prevents a bug in matplotlib where it expects a formatter attribute. The current format does not break the animation but you will see it if you click a chart while it is running and look in your terminal. It adds x and y axis data related to the chart as well as an []. The empty array has data by default that is quite meaningless so FormatStrFormatter("") gets rid of the data inside. closes #84
2 parents 9a50cbc + 86f4aad commit 270bcc3

15 files changed

Lines changed: 50 additions & 38 deletions

advection/simulation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import importlib
22
import numpy as np
3+
import matplotlib
34
import matplotlib.pyplot as plt
45

56
import advection.advective_fluxes as flx
@@ -118,6 +119,7 @@ def dovis(self):
118119

119120
# needed for PDF rendering
120121
cb = axes.cbar_axes[0].colorbar(img)
122+
cb.formatter = matplotlib.ticker.FormatStrFormatter("")
121123
cb.solids.set_rasterized(True)
122124
cb.solids.set_edgecolor("face")
123125

advection_nonuniform/simulation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import importlib
44
import numpy as np
5+
import matplotlib
56
import matplotlib.pyplot as plt
67

78
import advection_nonuniform.advective_fluxes as flx
@@ -145,6 +146,7 @@ def dovis(self):
145146

146147
# needed for PDF rendering
147148
cb = axes.cbar_axes[0].colorbar(img)
149+
cb.formatter = matplotlib.ticker.FormatStrFormatter("")
148150
cb.solids.set_rasterized(True)
149151
cb.solids.set_edgecolor("face")
150152

analysis/plotvar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ def makeplot(plotfile, variable, outfile,
3030
if log:
3131
var = np.log10(var)
3232

33-
plt.imshow(np.transpose(var.v()),
33+
img = plt.imshow(np.transpose(var.v()),
3434
interpolation="nearest", origin="lower",
3535
extent=[myg.xmin, myg.xmax, myg.ymin, myg.ymax])
3636

3737
if not compact:
38-
plt.colorbar()
38+
plt.colorbar(img)
3939

4040
plt.xlabel("x")
4141
plt.ylabel("y")

compressible/simulation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import importlib
44

55
import numpy as np
6+
import matplotlib
67
import matplotlib.pyplot as plt
78

89
import compressible.BC as BC
@@ -281,6 +282,7 @@ def dovis(self):
281282

282283
# needed for PDF rendering
283284
cb = axes.cbar_axes[n].colorbar(img)
285+
cb.formatter = matplotlib.ticker.FormatStrFormatter("")
284286
cb.solids.set_rasterized(True)
285287
cb.solids.set_edgecolor("face")
286288

compressible_react/simulation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import print_function
22

3+
import matplotlib
34
import matplotlib.pyplot as plt
45
import numpy as np
56

@@ -111,6 +112,7 @@ def dovis(self):
111112

112113
# needed for PDF rendering
113114
cb = axes.cbar_axes[n].colorbar(img)
115+
cb.formatter = matplotlib.ticker.FormatStrFormatter("")
114116
cb.solids.set_rasterized(True)
115117
cb.solids.set_edgecolor("face")
116118

diffusion/simulation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import importlib
44
import math
55
import numpy as np
6+
import matplotlib
67
import matplotlib.pyplot as plt
78

89
import mesh.patch as patch
@@ -135,7 +136,7 @@ def dovis(self):
135136

136137
myg = self.cc_data.grid
137138

138-
plt.imshow(np.transpose(phi.v()),
139+
img = plt.imshow(np.transpose(phi.v()),
139140
interpolation="nearest", origin="lower",
140141
extent=[myg.xmin, myg.xmax, myg.ymin, myg.ymax],
141142
cmap=self.cm)
@@ -144,7 +145,8 @@ def dovis(self):
144145
plt.ylabel("y")
145146
plt.title("phi")
146147

147-
plt.colorbar()
148+
cb = plt.colorbar(img)
149+
cb.formatter = matplotlib.ticker.FormatStrFormatter("")
148150

149151
plt.figtext(0.05, 0.0125, "t = {:10.5f}".format(self.cc_data.t))
150152

examples/multigrid/mg_test_general_alphabeta_only.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,27 +145,27 @@ def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False,
145145

146146
plt.subplot(121)
147147

148-
plt.imshow(np.transpose(v.v()),
148+
img1 = plt.imshow(np.transpose(v.v()),
149149
interpolation="nearest", origin="lower",
150150
extent=[a.xmin, a.xmax, a.ymin, a.ymax])
151151

152152
plt.xlabel("x")
153153
plt.ylabel("y")
154154
plt.title("nx = {}".format(nx))
155155

156-
plt.colorbar()
156+
plt.colorbar(img1)
157157

158158
plt.subplot(122)
159159

160-
plt.imshow(np.transpose(e.v()),
160+
img2 = plt.imshow(np.transpose(e.v()),
161161
interpolation="nearest", origin="lower",
162162
extent=[a.xmin, a.xmax, a.ymin, a.ymax])
163163

164164
plt.xlabel("x")
165165
plt.ylabel("y")
166166
plt.title("error")
167167

168-
plt.colorbar()
168+
plt.colorbar(img2)
169169

170170
plt.tight_layout()
171171

examples/multigrid/mg_test_general_beta_only.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,27 +145,27 @@ def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False,
145145

146146
plt.subplot(121)
147147

148-
plt.imshow(np.transpose(v.v()),
148+
img1 = plt.imshow(np.transpose(v.v()),
149149
interpolation="nearest", origin="lower",
150150
extent=[a.xmin, a.xmax, a.ymin, a.ymax])
151151

152152
plt.xlabel("x")
153153
plt.ylabel("y")
154154
plt.title("nx = {}".format(nx))
155155

156-
plt.colorbar()
156+
plt.colorbar(img1)
157157

158158
plt.subplot(122)
159159

160-
plt.imshow(np.transpose(e.v()),
160+
img2 = plt.imshow(np.transpose(e.v()),
161161
interpolation="nearest", origin="lower",
162162
extent=[a.xmin, a.xmax, a.ymin, a.ymax])
163163

164164
plt.xlabel("x")
165165
plt.ylabel("y")
166166
plt.title("error")
167167

168-
plt.colorbar()
168+
plt.colorbar(img2)
169169

170170
plt.tight_layout()
171171

examples/multigrid/mg_test_general_constant.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,27 +131,27 @@ def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False,
131131

132132
plt.subplot(121)
133133

134-
plt.imshow(np.transpose(v.v()),
134+
img1 = plt.imshow(np.transpose(v.v()),
135135
interpolation="nearest", origin="lower",
136136
extent=[a.xmin, a.xmax, a.ymin, a.ymax])
137137

138138
plt.xlabel("x")
139139
plt.ylabel("y")
140140
plt.title("nx = {}".format(nx))
141141

142-
plt.colorbar()
142+
plt.colorbar(img1)
143143

144144
plt.subplot(122)
145145

146-
plt.imshow(np.transpose(e.v()),
146+
img2 = plt.imshow(np.transpose(e.v()),
147147
interpolation="nearest", origin="lower",
148148
extent=[a.xmin, a.xmax, a.ymin, a.ymax])
149149

150150
plt.xlabel("x")
151151
plt.ylabel("y")
152152
plt.title("error")
153153

154-
plt.colorbar()
154+
plt.colorbar(img2)
155155

156156
plt.tight_layout()
157157

examples/multigrid/mg_test_general_dirichlet.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,27 +150,27 @@ def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False,
150150

151151
plt.subplot(121)
152152

153-
plt.imshow(np.transpose(v.v()),
153+
img1 = plt.imshow(np.transpose(v.v()),
154154
interpolation="nearest", origin="lower",
155155
extent=[a.xmin, a.xmax, a.ymin, a.ymax])
156156

157157
plt.xlabel("x")
158158
plt.ylabel("y")
159159
plt.title("nx = {}".format(nx))
160160

161-
plt.colorbar()
161+
plt.colorbar(img1)
162162

163163
plt.subplot(122)
164164

165-
plt.imshow(np.transpose(e.v()),
165+
img2 = plt.imshow(np.transpose(e.v()),
166166
interpolation="nearest", origin="lower",
167167
extent=[a.xmin, a.xmax, a.ymin, a.ymax])
168168

169169
plt.xlabel("x")
170170
plt.ylabel("y")
171171
plt.title("error")
172172

173-
plt.colorbar()
173+
plt.colorbar(img2)
174174

175175
plt.tight_layout()
176176

0 commit comments

Comments
 (0)