@brief Convert a Matplotlib figure to a PIL Image in RGBA format and return it @param fig a matplotlib figure @return a Python Imaging Library ( PIL ) image
(fig)
| 221 | |
| 222 | @staticmethod |
| 223 | def fig2img(fig): |
| 224 | """ |
| 225 | @brief Convert a Matplotlib figure to a PIL Image in RGBA format and return it |
| 226 | @param fig a matplotlib figure |
| 227 | @return a Python Imaging Library ( PIL ) image |
| 228 | """ |
| 229 | # put the figure pixmap into a numpy array |
| 230 | buf = ImageHelper.fig2data(fig) |
| 231 | h, w, d = buf.shape |
| 232 | return Image.frombytes("RGBA", (w, h), buf.tostring()) |
| 233 | |
| 234 | @staticmethod |
| 235 | def fig2np(fig): |