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

Skip to content

MEP12-on-barchart_demo2.py #4685

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

Merged
merged 6 commits into from
Jul 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 2 additions & 3 deletions examples/pylab_examples/barchart_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"""
import numpy as np
import matplotlib.pyplot as plt
import pylab
from matplotlib.ticker import MaxNLocator

student = 'Johnny Doe'
Expand All @@ -33,7 +32,7 @@
rects = ax1.barh(pos, rankings, align='center', height=0.5, color='m')

ax1.axis([0, 100, 0, 5])
pylab.yticks(pos, testNames)
plt.yticks(pos, testNames)
ax1.set_title('Johnny Doe')
plt.text(50, -0.5, 'Cohort Size: ' + str(cohortSize),
horizontalalignment='center', size='small')
Expand All @@ -43,7 +42,7 @@
ax2 = ax1.twinx()
ax2.plot([100, 100], [0, 5], 'white', alpha=0.1)
ax2.xaxis.set_major_locator(MaxNLocator(11))
xticks = pylab.setp(ax2, xticklabels=['0', '10', '20', '30', '40', '50', '60',
xticks = plt.setp(ax2, xticklabels=['0', '10', '20', '30', '40', '50', '60',
'70', '80', '90', '100'])
ax2.xaxis.grid(True, linestyle='--', which='major', color='grey',
alpha=0.25)
Expand Down
13 changes: 6 additions & 7 deletions examples/pylab_examples/barcode_demo.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from matplotlib.pyplot import figure, show, cm
from numpy import where
from numpy.random import rand
import matplotlib.pyplot as plt
import numpy as np

# the bar
x = where(rand(500) > 0.7, 1.0, 0.0)
x = np.where(np.random.rand(500) > 0.7, 1.0, 0.0)

axprops = dict(xticks=[], yticks=[])
barprops = dict(aspect='auto', cmap=cm.binary, interpolation='nearest')
barprops = dict(aspect='auto', cmap=plt.cm.binary, interpolation='nearest')

fig = figure()
fig = plt.figure()

# a vertical barcode -- this is broken at present
x.shape = len(x), 1
Expand All @@ -22,4 +21,4 @@
ax.imshow(x, **barprops)


show()
plt.show()
59 changes: 27 additions & 32 deletions examples/pylab_examples/boxplot_demo.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,52 @@
#!/usr/bin/python

#
# Example boxplot code
#

from pylab import *
import matplotlib.pyplot as plt
import numpy as np

# fake up some data
spread = rand(50) * 100
center = ones(25) * 50
flier_high = rand(10) * 100 + 100
flier_low = rand(10) * -100
data = concatenate((spread, center, flier_high, flier_low), 0)
spread = np.random.rand(50) * 100
center = np.ones(25) * 50
flier_high = np.random.rand(10) * 100 + 100
flier_low = np.random.rand(10) * -100
data = np.concatenate((spread, center, flier_high, flier_low), 0)

# basic plot
boxplot(data)
plt.boxplot(data)

# notched plot
figure()
boxplot(data, 1)
plt.figure()
plt.boxplot(data, 1)

# change outlier point symbols
figure()
boxplot(data, 0, 'gD')
plt.figure()
plt.boxplot(data, 0, 'gD')

# don't show outlier points
figure()
boxplot(data, 0, '')
plt.figure()
plt.boxplot(data, 0, '')

# horizontal boxes
figure()
boxplot(data, 0, 'rs', 0)
plt.figure()
plt.boxplot(data, 0, 'rs', 0)

# change whisker length
figure()
boxplot(data, 0, 'rs', 0, 0.75)
plt.figure()
plt.boxplot(data, 0, 'rs', 0, 0.75)

# fake up some more data
spread = rand(50) * 100
center = ones(25) * 40
flier_high = rand(10) * 100 + 100
flier_low = rand(10) * -100
d2 = concatenate((spread, center, flier_high, flier_low), 0)
spread = np.random.rand(50) * 100
center = np.ones(25) * 40
flier_high = np.random.rand(10) * 100 + 100
flier_low = np.random.rand(10) * -100
d2 = np.concatenate((spread, center, flier_high, flier_low), 0)
data.shape = (-1, 1)
d2.shape = (-1, 1)
#data = concatenate( (data, d2), 1 )
# data = concatenate( (data, d2), 1 )
# Making a 2-D array only works if all the columns are the
# same length. If they are not, then use a list instead.
# This is actually more efficient because boxplot converts
# a 2-D array into a list of vectors internally anyway.
data = [data, d2, d2[::2, 0]]
# multiple box plots on one figure
figure()
boxplot(data)
plt.figure()
plt.boxplot(data)

show()
plt.show()
10 changes: 4 additions & 6 deletions examples/pylab_examples/break.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
from pylab import *
import matplotlib.pyplot as plt

plt.gcf().text(0.5, 0.95, 'Distance Histograms by Category is \
a really long title')

gcf().text(0.5, 0.95,
'Distance Histograms by Category is a really long title')

show()
plt.show()
9 changes: 5 additions & 4 deletions examples/pylab_examples/clippedline.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
"""

from matplotlib.lines import Line2D
import matplotlib.pyplot as plt
import numpy as np
from pylab import figure, show


class ClippedLine(Line2D):
"""
Clip the xlimits to the axes view limits -- this example assumes x is sorted
Clip the xlimits to the axes view limits
this example assumes x is sorted
"""

def __init__(self, ax, *args, **kwargs):
Expand Down Expand Up @@ -45,7 +46,7 @@ def draw(self, renderer):
Line2D.draw(self, renderer)


fig = figure()
fig = plt.figure()
ax = fig.add_subplot(111, autoscale_on=False)

t = np.arange(0.0, 100.0, 0.01)
Expand All @@ -54,4 +55,4 @@ def draw(self, renderer):
ax.add_line(line)
ax.set_xlim(10, 30)
ax.set_ylim(-1.1, 1.1)
show()
plt.show()