2016-04-19 13 views
1

私は複数の数字を作成しましたが、一度にすべて表示したくないのですが、どのようにボタンやチェックボックスを使用できますか?Matplotlibチェックボックス(前と次)

私は次の、他の図の変更

私のコードが、このショーの2つの数字を中クリックして、私はこのようないけない:

import matplotlib.pyplot as plt 
intervals = ['52, 57', '57, 62', '62, 67', '67, 72', '72, 77', '77, 82', '82, 87'] 
absolute = [3, 11, 23, 27, 10, 5, 1] 
pos = np.arange(len(absolute)) 
# figure with bars fi 
width = 1.0 
fig1= plt.figure() 
ax1 = plt.axes() 
ax1.plot(pos, absolute, '-', linewidth=2) 


# figure with lines fi 
fig2 = plt.figure() 
pos = np.arange(len(absolute)) 
x = np.linspace(0, 10) 
ax = plt.axes() 
ax.plot(pos, absolute, '--', linewidth=2) 

plt.show() 

はどうもありがとうございました!

おはようございます!

+0

。スライダ(int、float)、ラジオボタン、コンボボックスなどがあります。 – roadrunner66

+0

[mcve]をご覧ください。実行可能でありながら最小限の例を人に与えるようにしてください。上の 'absolute_frecuency'のためのベクトルを提供します。 – roadrunner66

+0

ありがとう、おかげで、ごめん、訂正を待ちます – Milor123

答えて

1

Ipython(Jupyterノートブック)を使用すると、これはかなり見やすく簡単です。 キーワードboolは、チェックボックスを生成するために必要なものです。クリックすると、値とプロットが図のように変更されます。あなたはdefinitilyにIpython(Jupyter)ノートブックで `ipywidgets`を使用することができ

import numpy as np 
import matplotlib.pyplot as plt 
from ipywidgets import * 
%matplotlib inline 


t = np.arange(100) 
f=0.01 
data = np.sin(2*np.pi*f*t) 

def plot(lines): 
    fig1= plt.figure() 
    ax = plt.axes() 
    if lines: 
     ax.plot(t,data, '-', linewidth=2) 
    else: 
     ax.plot(t,data, '.', linewidth=2) 
interact(plot, lines=bool())  

enter image description here

enter image description here

+0

おかげで、これは私が望んでいたものではありませんが、これは非常に良い – Milor123

関連する問題