Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
Added function arguments to text describing the formatter
  • Loading branch information
rougier committed Sep 14, 2016
commit 6a3a5b884d10df6743ee64f301c692c428d4746a
10 changes: 5 additions & 5 deletions examples/ticks_and_spines/tick-formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def setup(ax):
else "" for x in np.arange(0, 5, 0.25)]
ax.xaxis.set_minor_formatter(ticker.FixedFormatter(minors))
ax.text(0.0, 0.5, "FixedFormatter(['','0','1',...])",
fontsize=16, transform=ax.transAxes)
fontsize=15, transform=ax.transAxes)


# Func formatter
Expand All @@ -61,7 +61,7 @@ def minor_formatter(x, pos):
ax.xaxis.set_major_locator(ticker.MultipleLocator(1.00))
ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.25))
ax.xaxis.set_major_formatter(ticker.FuncFormatter(major_formatter))
ax.text(0.0, 0.5, "FuncFormatter(myfunc)", fontsize=16, transform=ax.transAxes)
ax.text(0.0, 0.5, "FuncFormatter(myfunc)", fontsize=15, transform=ax.transAxes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FuncFormatter(lambda x, pos: "[%.2f]" % x) seems a better caption? Also, the minor_formatter function seems unused?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points.



# FormatStr formatter
Expand All @@ -71,15 +71,15 @@ def minor_formatter(x, pos):
ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.25))
ax.xaxis.set_major_formatter(ticker.FormatStrFormatter(">%d<"))
ax.text(0.0, 0.5, "FormatStrFormatter('>%d<')",
fontsize=16, transform=ax.transAxes)
fontsize=15, transform=ax.transAxes)

# Scalar formatter
ax = plt.subplot(n, 1, 5)
setup(ax)
ax.xaxis.set_major_locator(ticker.AutoLocator())
ax.xaxis.set_minor_locator(ticker.AutoMinorLocator())
ax.xaxis.set_major_formatter(ticker.ScalarFormatter(useMathText=True))
ax.text(0.0, 0.5, "ScalarFormatter()", fontsize=16, transform=ax.transAxes)
ax.text(0.0, 0.5, "ScalarFormatter()", fontsize=15, transform=ax.transAxes)

# StrMethod formatter
ax = plt.subplot(n, 1, 6)
Expand All @@ -88,7 +88,7 @@ def minor_formatter(x, pos):
ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.25))
ax.xaxis.set_major_formatter(ticker.StrMethodFormatter("{x}"))
ax.text(0.0, 0.5, "StrMethodFormatter('{x}')",
fontsize=16, transform=ax.transAxes)
fontsize=15, transform=ax.transAxes)


plt.tight_layout()
Expand Down