0
A
回答
2
您可以設置根據對劇情的位置箱的具體寬度。 boxplot
的參數width
允許設置不同的寬度。要計算相應的寬度,您需要將位置轉換爲線性比例,添加或減去一些線性寬度,然後轉換回對數比例。兩個因此獲得的值之間的差異是要設置的條的寬度。
線性寬度01當然在某種程度上是任意的;你需要爲自己選擇一個好的價值。
import matplotlib.pyplot as plt
import numpy as np; np.random.seed(42)
a = np.cumsum(np.random.rayleigh(150, size=(50,8)), axis=1)
fig, ax=plt.subplots()
positions=np.logspace(-0.1,2.6,8)
w = 0.1
width = lambda p, w: 10**(np.log10(p)+w/2.)-10**(np.log10(p)-w/2.)
ax.boxplot(a, positions=positions, widths=width(positions,w))
ax.set_xscale("log")
plt.show()
+0
這正是我所期待的。非常感謝。 – Tomas
相關問題
- 1. Matplotlib boxplot x軸
- 2. 使matplotlib boxplot的中線不可見
- 3. matplotlib邊框寬度
- 4. 從對角線和旋轉角度計算矩形的寬度和高度
- 5. 使用Matplotlib創建Boxplot
- 6. Matplotlib boxplot沒有異常值
- 7. Matplotlib:線寬被添加到線的長度
- 8. 保存PDF時matplotlib線寬
- 9. matplotlib集合線寬映射?
- 10. 試圖計算給定的寬度和對角線
- 11. matplotlib中帶有可變長度數據的Boxplot
- 12. 調整boxplot手臂寬度,並將水平線添加到底部和頂部
- 13. 如何繪製「兩個方向寬度線」在matplotlib
- 14. Matplotlib:繪製與數據座標中給定的寬度線
- 15. Matplotlib刻度對齊
- 16. Matplotlib圖中的進度線
- 17. 畫線寬度與橢圓寬度
- 18. 從matplotlib查找異常點:boxplot
- 19. 熊貓boxplot封面/覆蓋matplotlib圖
- 20. matplotlib subplot boxplot隱藏一些軸標籤
- 21. matplotlib boxplot xticks向y軸移動
- 22. Matplotlib 3D plot - 從某些角度看「參數化曲線」
- 23. 帶有固定角度的對角線與css中的曲線
- 24. Matplotlib - Boxplot計算log10值,但以對數形式顯示
- 25. matplotlib:改變幹情節線寬
- 26. matplotlib路徑線寬連接到圖zoom
- 27. 可變線寬的Matplotlib繪圖
- 28. Matplotlib表:單個列的寬度
- 29. Matplotlib估計文本寬度的錯誤
- 30. Matplotlib堆疊直方圖bin寬度
我想你應該添加代碼 –
不只是你的代碼,但[最小,完整,可驗證的示例](http://stackoverflow.com/help/mcve)。 – DavidG
[這個問題](https://stackoverflow.com/questions/44068435/setting-both-axes-logarithmic-in-bar-plot-matploblib)將相當於條形圖。 – ImportanceOfBeingErnest