保存交互式Pyplot图形

时间:2020-05-26 12:53:28

标签: python pandas matplotlib seaborn

我已经为一些同事提供了带有交互式检查按钮的pyplot。复选按钮显示相同的值,但来自不同的传感器。我想使用功能正常的检查按钮将生成的图发送给我的同事。但是,如果我将文件另存为JPG / PNG,该功能将丢失。有没有一种方法可以将带有功能性检查按钮的交互式python图形发送给不是python用户并且不真正了解编程的其他人?

代码不是非常相关,但是在下面发布:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import CheckButtons
### FIGURE 1 ###

fig, ax = plt.subplots()
l0, = ax.plot(df1[vel_avg1],df1[htc1],color = 'C0', marker = 'o', label = 'HTC-1')
l1, = ax.plot(df1[vel_avg2],df1[htc2],color = 'C0', marker = 'o',label = 'HTC-2')
l2, = ax.plot(x_th, y_th, color = 'r', marker = 'o', markersize=0,
              label = 'Theoretical heat transfer coefficient')

plt.subplots_adjust(left=0.2)
ax.set_xlabel('Off-gas velocity (m/s)', fontsize = SMALL_SIZE)
ax.set_ylabel('Heat transfer coefficient (W/m2K)', fontsize = SMALL_SIZE)
lines1 = [l0, l1, l2]

# Make checkbuttons with all plotted lines with correct visibility
rax = plt.axes([0.05, 0.4, 0.1, 0.15])
labels1 = [str(line.get_label()) for line in lines1]
visibility1 = [line.get_visible() for line in lines1]
check1 = CheckButtons(rax, ('HTC-1','HTC-2'), visibility1)

def func(label):
    index = labels1.index(label)
    lines1[index].set_visible(not lines1[index].get_visible())
    plt.draw()

check1.on_clicked(func)

plt.suptitle('From ' + start_date + ' to ' + end_date)
plt.savefig('fig1.png')
plt.show()

seaborn可能具有类似此库或任何其他库的功能吗?

0 个答案:

没有答案