Axis cuts off part of displayed graphics for default limits.

I created this graph below but if I set the y axis upper limit to 100. It cuts off the top half of the dots which are at 100. I wasn't sure how to get the dots to show properly like now but set the y-axis upper limit to 100 instead of like 102. It makes the data look misleading to have that little tail above 100. Essentially a way to create the axis but offset the actual axis grid to 95% of that or any other suggestions.

Cheers

Script used to create here:

import matplotlib.pyplot as plt
import matplotlib.ticker as tick
from numpy import load, sqrt, shape, size, loadtxt, transpose

def clear_spines(ax):
     ax.spines['top'].set_color('none')
     ax.spines['right'].set_color('none')
def set_spineLineWidth(ax, lineWidth):
     for i in ax.spines.keys():
         ax.spines[i].set_linewidth(lineWidth)
def showOnlySomeTicks(x, pos):
     s = str(int(x))
     if x == 5000:
         return '5e3'#'%.0e' % x
     return ''

plt.close('all')
golden_mean = (sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt # width in inches
fig_height = fig_width*golden_mean # height in inches
fig_size = [fig_width,fig_height]
tick_size = 9
fontlabel_size = 10.5
params = {'backend': 'wxAgg', 'axes.labelsize': fontlabel_size, 'text.fontsize': fontlabel_size, 'legend.fontsize': fontlabel_size, 'xtick.labelsize': tick_size, 'ytick.labelsize': tick_size, 'text.usetex': True, 'figure.figsize': fig_size}
plt.rcParams.update(params)
sizeX = storeMat[0].size
fig = plt.figure(1)
#figure(num=None, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
#fig.set_size_inches(fig_size)
plt.clf()
ax = plt.axes([0.145,0.18,0.95-0.155,0.95-0.2])
plt.plot(storeMat[0][::2],storeMat[1][::2]/300.*100,'ko',markersize=3.5)
#plt.plot(storeMat[0][::2],storeMat[1][::2]/300.*100,'k')
plt.ylim(0,102)
plt.xlabel('Number of Channels')
plt.ylabel('Recognition Accuracy')
set_spineLineWidth(ax,spineLineWidth)
clear_spines(ax)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
#ax.xaxis.set_minor_formatter(tick.FuncFormatter(showOnlySomeTicks))
#plt.legend()
for i in outExt:
     plt.savefig('lineVersion/'+outFile+i, dpi = mydpi)

RecogVsChannels.resized.png

···

--
________________________
Jeffrey Spencer
jeffspencerd@...287...

I created this graph below but if I set the y axis upper limit to 100.
It cuts off the top half of the dots which are at 100. I wasn't sure how
to get the dots to show properly like now but set the y-axis upper limit
to 100 instead of like 102. It makes the data look misleading to have
that little tail above 100. Essentially a way to create the axis but
offset the actual axis grid to 95% of that or any other suggestions.

Cheers

Try the changes indicated below.

Script used to create here:

import matplotlib.pyplot as plt
import matplotlib.ticker as tick
from numpy import load, sqrt, shape, size, loadtxt, transpose

def clear_spines(ax):
ax.spines['top'].set_color('none')
ax.spines['right'].set_color('none')
def set_spineLineWidth(ax, lineWidth):
for i in ax.spines.keys():
ax.spines[i].set_linewidth(lineWidth)
def showOnlySomeTicks(x, pos):
s = str(int(x))
if x == 5000:
return '5e3'#'%.0e' % x
return ''

plt.close('all')
golden_mean = (sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt # width in inches
fig_height = fig_width*golden_mean # height in inches
fig_size = [fig_width,fig_height]
tick_size = 9
fontlabel_size = 10.5
params = {'backend': 'wxAgg', 'axes.labelsize': fontlabel_size,
'text.fontsize': fontlabel_size, 'legend.fontsize': fontlabel_size,
'xtick.labelsize': tick_size, 'ytick.labelsize': tick_size,
'text.usetex': True, 'figure.figsize': fig_size}
plt.rcParams.update(params)
sizeX = storeMat[0].size
fig = plt.figure(1)
#figure(num=None, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
#fig.set_size_inches(fig_size)
plt.clf()
ax = plt.axes([0.145,0.18,0.95-0.155,0.95-0.2])

pts, = plt.plot(storeMat[0][::2],storeMat[1][::2]/300.*100,'ko',markersize=3.5)
# Note: the comma after "pts" is intentional.
pts.set_clip_on(False)

#plt.plot(storeMat[0][::2],storeMat[1][::2]/300.*100,'k')

plt.ylim(0,100)

···

On 08/24/2011 06:53 AM, Jeffrey Spencer wrote:

plt.xlabel('Number of Channels')
plt.ylabel('Recognition Accuracy')
set_spineLineWidth(ax,spineLineWidth)
clear_spines(ax)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
#ax.xaxis.set_minor_formatter(tick.FuncFormatter(showOnlySomeTicks))
#plt.legend()
for i in outExt:
plt.savefig('lineVersion/'+outFile+i, dpi = mydpi)

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management
Up to 160% more powerful than alternatives and 25% more efficient.
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

That does the trick. Didn't know where the clipping was occurring but couldn't find anything in plot so makes sense it was in the line. Assuming the comma just unpacks the tuple to get direct access to line.

Thanks for the help

···

On 25/08/11 03:23, Eric Firing wrote:

On 08/24/2011 06:53 AM, Jeffrey Spencer wrote:

I created this graph below but if I set the y axis upper limit to 100.
It cuts off the top half of the dots which are at 100. I wasn't sure how
to get the dots to show properly like now but set the y-axis upper limit
to 100 instead of like 102. It makes the data look misleading to have
that little tail above 100. Essentially a way to create the axis but
offset the actual axis grid to 95% of that or any other suggestions.

Cheers

Try the changes indicated below.

Script used to create here:

import matplotlib.pyplot as plt
import matplotlib.ticker as tick
from numpy import load, sqrt, shape, size, loadtxt, transpose

def clear_spines(ax):
ax.spines['top'].set_color('none')
ax.spines['right'].set_color('none')
def set_spineLineWidth(ax, lineWidth):
for i in ax.spines.keys():
ax.spines[i].set_linewidth(lineWidth)
def showOnlySomeTicks(x, pos):
s = str(int(x))
if x == 5000:
return '5e3'#'%.0e' % x
return ''

plt.close('all')
golden_mean = (sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt # width in inches
fig_height = fig_width*golden_mean # height in inches
fig_size = [fig_width,fig_height]
tick_size = 9
fontlabel_size = 10.5
params = {'backend': 'wxAgg', 'axes.labelsize': fontlabel_size,
'text.fontsize': fontlabel_size, 'legend.fontsize': fontlabel_size,
'xtick.labelsize': tick_size, 'ytick.labelsize': tick_size,
'text.usetex': True, 'figure.figsize': fig_size}
plt.rcParams.update(params)
sizeX = storeMat[0].size
fig = plt.figure(1)
#figure(num=None, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
#fig.set_size_inches(fig_size)
plt.clf()
ax = plt.axes([0.145,0.18,0.95-0.155,0.95-0.2])

pts, =
plt.plot(storeMat[0][::2],storeMat[1][::2]/300.*100,'ko',markersize=3.5)
# Note: the comma after "pts" is intentional.
pts.set_clip_on(False)

#plt.plot(storeMat[0][::2],storeMat[1][::2]/300.*100,'k')

plt.ylim(0,100)

plt.xlabel('Number of Channels')
plt.ylabel('Recognition Accuracy')
set_spineLineWidth(ax,spineLineWidth)
clear_spines(ax)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
#ax.xaxis.set_minor_formatter(tick.FuncFormatter(showOnlySomeTicks))
#plt.legend()
for i in outExt:
plt.savefig('lineVersion/'+outFile+i, dpi = mydpi)

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management
Up to 160% more powerful than alternatives and 25% more efficient.
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management
Up to 160% more powerful than alternatives and 25% more efficient.
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options