Why axes is not visible when used with figure.add_axes ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Why axes is not visible when used with figure.add_axes ?

Shiyao Ma
Hi,

I have the following snippet to reproduce my problem:


import numpy as np
import matplotlib.pyplot as plt

y = np.arange(4)
x = np.arange(4)

fig = plt.figure()
ax = fig.add_axes([0, 0, 1, 1])
ax.plot(x, y)
ax.set_title('test')
ax.set_xlabel("XX")
plt.show()


The picture is here:


Why are the X/Y axes, the title, and the label not visible?

Regards.

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why axes is not visible when used with figure.add_axes ?

Fabrice Silva-2
Le samedi 17 décembre 2016, Shiyao Ma a écrit :

> Hi,
>
> I have the following snippet to reproduce my problem:
>
>
> import numpy as np
> import matplotlib.pyplot as plt
>
> y = np.arange(4)
> x = np.arange(4)
>
> fig = plt.figure()
> ax = fig.add_axes([0, 0, 1, 1])
> ax.plot(x, y)
> ax.set_title('test')
> ax.set_xlabel("XX")
> plt.show()
>
>
> The picture is here:
> http://imgur.com/a/1fh3u
>
>
> Why are the X/Y axes, the title, and the label not visible?

The bounds you provided to the add_axes method specify that the
axes spans all the figure. In fact [0,0,1,1] means that
- the lower left corner is at coordinate (0,0) of the figure canvas
- it spans the full width and height (1,1) of the canvas.
So that the ticklabels, labels and title are outside of the visible
part of the figure.

Reduce the bounds (or even use add_subplot(1,1,1)) to get a suitable
axes.
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Loading...