Just in case, if anyone needs the answer, I figured it out.
I used the transData transform in order to draw the lines correctly.

Here is the code - 

# The code below is to add the lines near the tick labels
fig = barGraph.fig
xAxisLim=barGraph.ax.xaxis.get_view_interval()
tickLocArray = barGraph.ax.xaxis.get_majorticklocs()
yStart=-70
yEnd=-0.5
line = Line2D([xAxisLim[0], xAxisLim[0]], 
              [yStart,yEnd],linewidth=2, color='black',
               transform=barGraph.ax.transData)

fig.lines.append(line)

for i in xrange(11):
    lnWidth=2
    yStartOffset=0
    if((i+1)%4 != 0):
        lnWidth=1
        yStartOffset=20  
    xOffset = tickLocArray[i] + (tickLocArray[i+1] - tickLocArray[i])/2
    line = Line2D([xOffset, xOffset], 
              [yStart+yStartOffset,yEnd],linewidth=lnWidth, color='black',
               transform=barGraph.ax.transData)  
    fig.lines.append(line)
    
              
line = Line2D([xAxisLim[1], xAxisLim[1]], 
              [yStart,yEnd],linewidth=2, color='black',
               transform=barGraph.ax.transData)

fig.lines.append(line)

plt.figtext(0.247, 0.05, '1')
plt.figtext(0.523, 0.05, '2')
plt.figtext(0.797, 0.05, '4')


Thank You!
Raj


rajtendulkar wrote:
> 
> Dear All,
> 
> I am trying to write a program in matplotlib to generate stacked bar
> graphs.
> My problem is that the commands -  plt.show() and
> self.fig.savefig(fileName) generate different outputs.
> I tried different output formats like PDF, PNG, EPS. But the problem
> remains the same.
> This happens for the lines that I am trying to draw outside the plot.
> I am trying to draw vertical lines between xticklabels.
> I have uploaded the data file and the code file.
>  http://old.nabble.com/file/p33893817/data.dat data.dat 
>  http://old.nabble.com/file/p33893817/matplot1.py matplot1.py 
> Could anyone explain how to resolve this problem?
> 
> Thank You,
> Raj
> 

-- 
View this message in context: 
http://old.nabble.com/Difference-in-show-and-output-file-tp33893817p33894599.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to