def test_mpl_preserve_image_tight(): """Make sure that the figure preserves height settings""" f = create_figure() exp = mplhooks.figure_to_rgb_array(f) width, height = f.canvas.get_width_height() mplhooks.figure_to_tight_array(f, 0.5 * width, 0.5 * height, True) obs = mplhooks.figure_to_rgb_array(f) plt.close(f) assert np.all(exp == obs)
def test_mpl_preserve_dpi(): """Make sure that the figure preserves height settings""" f = create_figure() width, height = f.canvas.get_width_height() mplhooks.figure_to_tight_array(f, 0.5 * width, 0.5 * height, False) exp = DPI obs = f.dpi plt.close(f) assert exp == obs
def test_mpl_preserve_face_color(): """Make sure that the figure preserves face color settings""" f = create_figure() width, height = f.canvas.get_width_height() mplhooks.figure_to_tight_array(f, 0.5 * width, 0.5 * height, True) exp = FACE_COLOR obs = f.get_facecolor() plt.close(f) assert exp == obs
def test_mpl_preserve_height(): """Make sure that the figure preserves height settings""" f = create_figure() width, height = f.canvas.get_width_height() mplhooks.figure_to_tight_array(f, 0.5 * width, 0.5 * height, True) exp = height newwidth, newheight = f.canvas.get_width_height() obs = newheight plt.close(f) assert exp == obs
def test_mpl_preserve_font_size(): """Make sure that matplotlib preserves font size settings""" f = create_figure() width, height = f.canvas.get_width_height() print(width, height) mplhooks.figure_to_tight_array(f, 0.5 * width, 0.5 * height, True) exp = FONT_SIZE obs = matplotlib.rcParams["font.size"] plt.close(f) assert exp == obs
def test_mpl_preserve_image_tight(): """Make sure that the figure preserves height settings""" f = create_figure() exp = mplhooks.figure_to_rgb_array(f) width, height = f.canvas.get_width_height() s = mplhooks.figure_to_tight_array(f, 0.5 * width, 0.5 * height, True) obs = mplhooks.figure_to_rgb_array(f) plt.close(f) assert np.all(exp == obs)
def test_mpl_preserve_dpi(): """Make sure that the figure preserves height settings""" f = create_figure() width, height = f.canvas.get_width_height() s = mplhooks.figure_to_tight_array(f, 0.5 * width, 0.5 * height, False) exp = DPI obs = f.dpi plt.close(f) assert exp == obs
def test_mpl_preserve_face_color(): """Make sure that the figure preserves face color settings""" f = create_figure() width, height = f.canvas.get_width_height() s = mplhooks.figure_to_tight_array(f, 0.5 * width, 0.5 * height, True) exp = FACE_COLOR obs = f.get_facecolor() plt.close(f) assert exp == obs
def test_mpl_preserve_font_size(): """Make sure that matplotlib preserves font size settings""" f = create_figure() width, height = f.canvas.get_width_height() s = mplhooks.figure_to_tight_array(f, 0.5*width, 0.5*height, True) exp = FONT_SIZE obs = matplotlib.rcParams['font.size'] plt.close(f) assert exp == obs
def test_mpl_preserve_height(): """Make sure that the figure preserves height settings""" f = create_figure() width, height = f.canvas.get_width_height() s = mplhooks.figure_to_tight_array(f, 0.5 * width, 0.5 * height, True) exp = height newwidth, newheight = f.canvas.get_width_height() obs = newheight plt.close(f) assert exp == obs