Created
May 20, 2014 02:05
-
-
Save jesserobertson/ac067998a04dd7349b21 to your computer and use it in GitHub Desktop.
Contourf with log scale bug in mpld3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Plot to test line contours""" | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import matplotlib.mlab as mlab | |
import mpld3 | |
def create_plot(): | |
x = np.linspace(-3.0, 3.0, 30) | |
y = np.linspace(-2.0, 2.0, 30) | |
X, Y = np.meshgrid(x, y) | |
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) | |
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) | |
Z = 10.0 * (Z2 - Z1) | |
fig, ax = plt.subplots() | |
CS = ax.contourf(X + 4, Y + 4, Z, 30) | |
ax.set_xscale('log') | |
return fig | |
def test_contourf(): | |
fig = create_plot() | |
html = mpld3.fig_to_html(fig) | |
plt.close(fig) | |
if __name__ == "__main__": | |
mpld3.show(create_plot()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment