SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S






1
2
(3)
3
(7)
4
(7)
5
(9)
6
(6)
7
8
(2)
9
10
11
12
(8)
13
(5)
14
(3)
15
(1)
16
(2)
17
(4)
18
(4)
19
20
21
(3)
22
(2)
23
24
(1)
25
26
27
28
(1)
29
30
31





Showing 1 results of 1

Revision: 8935
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8935&view=rev
Author: pivanov314
Date: 2011年01月24日 09:41:49 +0000 (2011年1月24日)
Log Message:
-----------
new broken axis example
Added Paths:
-----------
 trunk/matplotlib/examples/pylab_examples/broken_axis.py
Added: trunk/matplotlib/examples/pylab_examples/broken_axis.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/broken_axis.py	 (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/broken_axis.py	2011年01月24日 09:41:49 UTC (rev 8935)
@@ -0,0 +1,61 @@
+"""
+Broken axis example, where the y-axis will have a portion cut out.
+"""
+import matplotlib.pylab as plt
+import numpy as np
+
+
+# 30 points between 0 0.2] originally made using np.random.rand(30)*.2
+pts = np.array([ 0.015, 0.166, 0.133, 0.159, 0.041, 0.024, 0.195,
+ 0.039, 0.161, 0.018, 0.143, 0.056, 0.125, 0.096, 0.094, 0.051,
+ 0.043, 0.021, 0.138, 0.075, 0.109, 0.195, 0.05 , 0.074, 0.079,
+ 0.155, 0.02 , 0.01 , 0.061, 0.008])
+
+# Now let's make two outlier points which are far away from everything. 
+pts[[3,14]] += .8
+
+# If we were to simply plot pts, we'd lose most of the interesting
+# details due to the outliers. So let's 'break' or 'cut-out' the y-axis
+# into two portions - use the top (ax) for the outliers, and the bottom
+# (ax2) for the details of the majority of our data
+f,(ax,ax2) = plt.subplots(2,1,sharex=True)
+
+# plot the same data on both axes
+ax.plot(pts)
+ax2.plot(pts)
+
+# zoom-in / limit the view to different portions of the data
+ax.set_ylim(.78,1.) # outliers only
+ax2.set_ylim(0,.22) # most of the data
+
+# hide the spines between ax and ax2
+ax.spines['bottom'].set_visible(False)
+ax2.spines['top'].set_visible(False)
+ax.xaxis.tick_top()
+ax.tick_params(labeltop='off') # don't put tick labels at the top
+ax2.xaxis.tick_bottom()
+
+# This looks pretty good, and was fairly painless, but you can get that
+# cut-out diagonal lines look with just a bit more work. The important
+# thing to know here is that in axes coordinates, which are always
+# between 0-1, spine endpoints are at these locations (0,0), (0,1),
+# (1,0), and (1,1). Thus, we just need to put the diagonals in the
+# appropriate corners of each of our axes, and so long as we use the
+# right transform and disable clipping.
+
+d = .015 # how big to make the diagonal lines in axes coordinates
+# arguments to pass plot, just so we don't keep repeating them
+kwargs = dict(transform=ax.transAxes, color='k', clip_on=False)
+ax.plot((-d,+d),(-d,+d), **kwargs) # top-left diagonal
+ax.plot((1-d,1+d),(-d,+d), **kwargs) # top-right diagonal
+
+kwargs.update(transform=ax2.transAxes) # switch to the bottom axes
+ax2.plot((-d,+d),(1-d,1+d), **kwargs) # bottom-left diagonal
+ax2.plot((1-d,1+d),(1-d,1+d), **kwargs) # bottom-right diagonal
+
+# What's cool about this is that now if we vary the distance between
+# ax and ax2 via f.subplots_adjust(hspace=...) or plt.subplot_tool(),
+# the diagonal lines will move accordingly, and stay right at the tips
+# of the spines they are 'breaking'
+
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 1 results of 1

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /