8000 Fixing osx makefile by fgb · Pull Request #4 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fixing osx makefile #4

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

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clabel accepts callable as fmt kwarg; modified patch by Daniel Hyams
  • Loading branch information
efiring authored and fgb committed Feb 23, 2011
commit ff4a5921beccf1702d57e83b7860c4b43ba38715
3 changes: 3 additions & 0 deletions CHANGELOG
8000
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2011-02-20 clabel accepts a callable as an fmt kwarg; modified
patch by Daniel Hyams. - EF

2011-02-18 scatter([], []) is now valid. Also fixed issues
with empty collections - BVR

Expand Down
15 changes: 12 additions & 3 deletions examples/pylab_examples/contour_label_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy as np
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.ticker as ticker
import matplotlib.pyplot as plt

matplotlib.rcParams['xtick.direction'] = 'out'
Expand Down Expand Up @@ -68,7 +69,15 @@ def __repr__(self):
# Label every other level using strings
plt.clabel(CS,CS.levels[::2],inline=True,fmt=fmt,fontsize=10)

##################################################
# Show the hole thing
##################################################
# Use a Formatter

plt.figure()

CS = plt.contour(X, Y, 100**Z, locator=plt.LogLocator())
fmt = ticker.LogFormatterMathtext()
fmt.create_dummy_axis()
plt.clabel(CS, CS.levels, fmt=fmt)
plt.title("$100^Z$")

plt.show()

6 changes: 5 additions & 1 deletion lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def clabel(self, *args, **kwargs):
a format string for the label. Default is '%1.3f'
Alternatively, this can be a dictionary matching contour
levels with arbitrary strings to use for each contour level
(i.e., fmt[level]=string)
(i.e., fmt[level]=string), or it can be any callable, such
as a :class:`~matplotlib.ticker.Formatter` instance, that
returns a string when called with a numeric contour level.

*manual*:
if *True*, contour labels will be placed manually using
Expand Down Expand Up @@ -326,6 +328,8 @@ def get_text(self, lev, fmt):
else:
if isinstance(fmt,dict):
return fmt[lev]
elif callable(fmt):
return fmt(lev)
else:
return fmt%lev

Expand Down
0