0

I'm running the latest matplotlib version from the git repo (1.5-dev1) on python 2.7. For some reason, I can't seem to get a box visible around the plot. Here is an example -

plot( [1,2,3], [1,2,3] ) enter image description here

Now, when I interrogated this plot (in IPython) :

In [29]: ax=gca()

In [30]: ax.get_frame_on()

Out[30]: True

I've even tried changing matplotlib backends between Qt4Agg,TkAgg and GTKAgg, and there seems to be no difference. I've even tried matplotlib 1.4.2 and 1.3.1, but the results are the same.

Is there some option I'm missing when making these plots?

EDIT : @ThePredator just pointed to an answer, but that's not what I'm looking for. I simply want a box, whose borders are the plot's axes. I'm looking for an equivalent to the box('on') function in MATLAB.

vishakad
  • 567
  • 1
  • 6
  • 7
  • perhaps http://stackoverflow.com/questions/14908576/how-to-remove-frame-from-matplotlib-pyplot-figure-vs-matplotlib-figure-frame might help – Srivatsan Jan 21 '15 at 08:59
  • Nope. What I want are black lines around the plot, much like the matlab box('on') function. I'll make the question more clear, though. – vishakad Jan 21 '15 at 10:52
  • It looks like you're using [Seaborn](http://stanford.edu/~mwaskom/software/seaborn/) which [defaults](http://stanford.edu/~mwaskom/software/seaborn/tutorial/aesthetics.html) to not having borders. – Greg Jan 21 '15 at 11:42
  • I was importing seaborn earlier, but I shifted to purely matplotlib while trying this out. I managed to figure it out below though :) – vishakad Jan 21 '15 at 13:48

1 Answers1

0

Managed to find the answer.

Turns out that for some reason, the default line width of the spines of the axis were set to zero.

In [125]: for item in ['left','right','top','bottom']:
               print ax.spines[item].get_linewidth( )

0.0
0.0
0.0
0.0

Running ax.spines[item].set_linewidth( 1 ) seemed to rectify the problem.

vishakad
  • 567
  • 1
  • 6
  • 7