gnuplot vs Matplotlib
-
06-09-2019 - |
質問
をしたいプロジェクトグラフデータ Tomcat ログ用 gnuplot-py, での具体的な介入の特定の要求をメモリ割り当て、ガベージコレクション何 英知gnuplot-py vs Matplotlib Pythonグラフ化を行う.がよりよいグラフデータ図書館のあんなに聞いた。
私の一般的:
- なgnuplotは大量の文書、gnuplot-pyは来ない。どのように良いドキュメニュー Matplotlib?
- あるものgnuplotできないが、gnuplot-pyできない?
- なMatplotlibよPython収録時間はどのくらいですか。
- があるのは大きなショー停止のバグですか?Annoyances?
- 現在、gnuplotはグラフデータ100,000のポイントというスケールこまでなりました。は期待したいです。してはどうかMatplotlibを扱う。
- 使いやすさ、時間の大幅な削減を実現しgnuplot vs Matplotlib?
- どれほど簡単なる既存のポートgnuplot-pyコードMatplotlib?
ただしこのアプローチす。
解決
- 確認できます matplotlibのドキュメント ます。思うのですか。
- 私は非常に経験の少ないgnuplot-pyういうことはできないかどうかをすることができgnuplotできます。
- Matplotlibは、専用のPythonでの様子をよく見て、発見したことはとてもよくPythonイディオム。
- Matplotlibは、成熟したプロジェクト.NASAである。
- 私はプロット数千万点Matplotlibいた美しいと回答した。
- を超えてオブジェクト指向方法を用いMatplotlibをpylabインタフェースをプロットのとっても簡単でMATLAB、とても簡単です。
- として移植からgnuplot-pyにmatplotlibを持っていません。
他のヒント
Matplotlib=使いやすさ、Gnuplot=昇とともにより良い性能
この投稿は古いですが、答えした通りすがりしたかったので入れるにあたっては、自分のセント.ここでは私の結論またどこかで聞いたような、ビッグデータセットを使用してみてくださいMatplotlib.るのが難しいのですが、見栄えを良くするためただし、 本当に 必要な性能、利なGnuplot.私は追加のコードで利用するマシンを見て自分であれば、グアダラハラアセンブリを見る事ができ、リアルなパフォーマンスのベンチマークがはずがある。
以下のグラフを表すのに必要な時間(秒):
- プロットのランダムに散布グラフ
- 保存グラフをpngファイル
構成:
- gnuplot:5.2.2
- gnuplot-py:1.8
- matplotlib:2.1.2
思い出のギャップがより広く実行する場合は、古いコンピュータにより以前のバージョンでのライブラリー(30秒差の大きい散布図).
また、mentionnedのコメントを、同等の品質を推定した。ものであり汗ることでGnuplot.
こちらのコード生成のグラフ たい場合にはぜひ試してみてください利用するマシン:
# -*- coding: utf-8 -*-
from timeit import default_timer as timer
import matplotlib.pyplot as plt
import Gnuplot, Gnuplot.funcutils
import numpy as np
import sys
import os
def mPlotAndSave(x, y):
plt.scatter(x, y)
plt.savefig('mtmp.png')
plt.clf()
def gPlotAndSave(data, g):
g("set output 'gtmp.png'")
g.plot(data)
g("clear")
def cleanup():
try:
os.remove('gtmp.png')
except OSError:
pass
try:
os.remove('mtmp.png')
except OSError:
pass
begin = 2
end = 500000
step = 10000
numberOfPoints = range(begin, end, step)
n = len(numberOfPoints)
gnuplotTime = []
matplotlibTime = []
progressBarWidth = 30
# Init Gnuplot
g = Gnuplot.Gnuplot()
g("set terminal png size 640,480")
# Init matplotlib to avoid a peak in the beginning
plt.clf()
for idx, val in enumerate(numberOfPoints):
# Print a nice progress bar (crucial)
sys.stdout.write('\r')
progress = (idx+1)*progressBarWidth/n
bar = "▕" + "▇"*progress + "▁"*(progressBarWidth-progress) + "▏" + str(idx) + "/" + str(n-1)
sys.stdout.write(bar)
sys.stdout.flush()
# Generate random data
x = np.random.randint(sys.maxint, size=val)
y = np.random.randint(sys.maxint, size=val)
gdata = zip(x,y)
# Generate string call to a matplotlib plot and save, call it and save execution time
start = timer()
mPlotAndSave(x, y)
end = timer()
matplotlibTime.append(end - start)
# Generate string call to a gnuplot plot and save, call it and save execution time
start = timer()
gPlotAndSave(gdata, g)
end = timer()
gnuplotTime.append(end - start)
# Clean up the files
cleanup()
del g
sys.stdout.write('\n')
plt.plot(numberOfPoints, gnuplotTime, label="gnuplot")
plt.plot(numberOfPoints, matplotlibTime, label="matplotlib")
plt.legend(loc='upper right')
plt.xlabel('Number of points in the scatter graph')
plt.ylabel('Execution time (s)')
plt.savefig('execution.png')
plt.show()
は、長い時間のために(私自身のPythonラッパーで)GNUplotという紹介を使用して(そして実際に80年代に見える出力を好きではない)した後、私はmatplotlibのを見た始めました。私はそれが非常に多く、出力は本当に良さそうに見えますが好きと(それもGNUplotという紹介のために行くが)ドキュメントは、高品質と豊富にあると言わなければなりません。私はmatplotlibのドキュメントで探し年代を過ごした一つのことは、画像ファイルにではなく、画面に書き込む方法です!幸運なことに、このページには、かなりよくそれを説明する:のhttp:// WWW .dalkescientific.com /執筆/日記/アーカイブ/ 2005/04/23 / matplotlib_without_gui.htmlする
私は両方を果たしている、と私はPythonの統合、オプション、およびグラフ/プロットの品質の面ではるかに優れmatplotlibのが好き。
何gnuplotはgnuplotの-Pyはあまりにも行うことができます行うことができます。 gnuplotのパイプ(pgnuplot)で駆動することができるからです。 gnuplotの-Pyがそれのためだけの薄い層です。だから、あなたはそれを心配する必要はありません。
なぜ私は多分論文に非常に有用である多くの出力形式(PDF、PSおよびラテックス)、gnuplotのを好む、とデフォルトの出力は、より科学的なスタイルに見える:)
パフォーマンスとポイントの多くをプロットについて:私はgnuplotの*とmatplotlibのを使用して、500.000ポイントテキストファイルからロードされ、PNGに保存されたの散布のためにこれを比較した。
500.000 points scatterplot
gnuplot: 5.171 s
matplotlib: 230.693 s
私は一度だけ、それを実行し、結果は同じに見えるしていないが、私はアイデアは明らかだと思う:gnuplotはパフォーマンスで勝利。
* gnuplotpyデモは私のためのアウトボックスは動作しませんので、私はgnuplotの直接使用。 matplotlibのは、Pythonの統合で勝利します。