-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
contour and contourf treat levels differently #10572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A work around can be found here: https://stackoverflow.com/questions/18599625/matplotlib-standard-colormap-usage |
Could you post an example that uses generated data instead of data in files? Maybe using |
This is an example with generated data. This script plots two figures. One with a range of 100:-100 and one 40:-40. They should both be 100:-100. import numpy as np
import matplotlib.pyplot as plt
levels = np.arange(-100, 100, 10)
# Data to plot.
x, y = np.meshgrid(np.arange(10), np.arange(10))
z = 50*np.sin(0.5 * x) * np.cos(0.52 * y)
plt.figure(1)
CS = plt.contourf(x, y, z, levels)
CB = plt.colorbar(CS)
plt.figure(2)
CS = plt.contour(x, y, z, levels)
CB = plt.colorbar(CS)
plt.show() |
Note: If you want to have levels in the range -100:100, you have to to use either I can reproduce the issue. Not sure which behavior is intended, but they should be the same. |
Bug report
Bug summary
When setting levels that span a wider range of values than the data set, contourf correctly picks the right colors to fill the areas between the contour lines. contour does not use the same colors.
Code for reproduction
The data is attached.
Actual outcome
When plotting with contour instead of contourf the colors range is scaled according to the maximum and minimum of the used data.
Expected outcome
I would expect contour to respect the range set in levels.
Matplotlib version
print(matplotlib.get_backend())
): TkAggz.txt
y.txt
x.txt
Installed from Debian package
The text was updated successfully, but these errors were encountered: