matplotlibのようにプロットするのは可能ですか?私は赤い塗りつぶしの四角形だけを気にし、十字は簡単にerrorbar
で行われます。四角形を描画matplotlib(四角形)の塗りつぶしエラーバー
1
A
答えて
3
残念ながらerrorbar
これを行うことはできませんが、あなたはどのあなたのエラーデータからPatchCollection
を作成することができます軸に簡単に追加できます。どのようにこれを行うことができるかの例については、このクイックスクリプトを参照してください。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import PatchCollection
from matplotlib.patches import Rectangle
# Number of data points
n=5
# Dummy data
x=np.arange(0,n,1)
y=np.random.rand(n)*5.
# Dummy errors (above and below)
xerr=np.random.rand(2,n)
yerr=np.random.rand(2,n)
# Create figure and axes
fig,ax = plt.subplots(1)
# Plot data points
ax.errorbar(x,y,xerr=xerr,yerr=yerr,fmt='None',ecolor='k')
# Function to plot error boxes
def makeErrorBoxes(xdata,ydata,xerror,yerror,fc='r',ec='None',alpha=0.5):
# Create list for all the error patches
errorboxes = []
# Loop over data points; create box from errors at each point
for xc,yc,xe,ye in zip(xdata,ydata,xerror.T,yerror.T):
rect = Rectangle((xc-xe[0],yc-ye[0]),xe.sum(),ye.sum())
errorboxes.append(rect)
# Create patch collection with specified colour/alpha
pc = PatchCollection(errorboxes,facecolor=fc,alpha=alpha,edgecolor=ec)
# Add collection to axes
ax.add_collection(pc)
# Call function to create error boxes
makeErrorBoxes(x,y,xerr,yerr)
# Add some space around the data points on the axes
ax.margins(0.1)
plt.show()
2
例えば、matplotlib.patches
と本当に簡単です:
import matplotlib.pyplot as pl
import matplotlib.patches
pl.figure()
ax = pl.gca()
ax.add_patch(
matplotlib.patches.Rectangle(
(1.0, 1.0), # x, y
2.0, # width
2.0, # height
color='r', alpha=0.5
))
ax.set_aspect(1)
pl.xlim(0,4)
pl.ylim(0,4)
関連する問題
- 1. 四角形を塗りつぶす
- 2. Silverlightで四角形を部分的に塗りつぶす
- 3. キャンバス描画線形勾配で四角形を塗りつぶし
- 4. 三角形を塗りつぶすアルゴリズム
- 5. 四角形を順番に塗りつぶしていく方法は?
- 6. Rヒートマップで空の四角を塗りつぶし
- 7. gnuplotの四角形の下の色を塗りつぶす方法は?
- 8. Matplotlib - 塗りつぶしのトラブル
- 9. カレンダーの正方形の半角の塗りつぶし
- 10. 矩形ペイントメソッド(MIDP)の塗りつぶし
- 11. 円を六角形で塗りつぶし
- 12. グラデーションを塗りつぶしたMathplotlib描画三角形
- 13. 円に六角形を塗りつぶす(別のアプローチ)
- 14. 3Dマットプリティブプロットの三角形をカラーグラデーションで塗りつぶす
- 15. libgdxのテキストの後ろに塗りつぶした四角形を描くには?
- 16. Silverlight - カスタムUserControlで四角形(またはBrushプロパティを持つ他のコントロール)を塗りつぶす
- 17. VB.NET図形の錯綜する形の塗りつぶし形
- 18. 部分的に塗りつぶされたCSS三角形
- 19. 配列内の数字に対応する行の四角形の数を塗りつぶす方法。 d3.js
- 20. 3面体に四面体を塗りつぶし
- 21. matplotlibマーカーの複数の色の塗りつぶし
- 22. matplotlibグラフの塗りつぶし軸の上下2色
- 23. matplotlib:塗りつぶしのボックスプロットとポイント表示
- 24. SVG一角コーナー四角形/四角形
- 25. ダブル塗りを使用したJavaの塗りつぶしの矩形
- 26. 塗りつぶし(bashの)
- 27. 周囲の六角形を「線」塗りつぶしモードに変更する
- 28. マウスクリックで三角形の塗りつぶし色を入力する
- 29. 塗りつぶされた図形と塗りつぶされていない図形[宿題]
- 30. Matplotlibで複数の行を塗りつぶす
これをmplドキュメントの例として提出できますか? – tacaswell
@tcaswell:はい。私は ''例/統計 ''の中でそれをやったと思うが、私はgitに新しいので、私が何か間違っていたら教えてください:) – tom