Mmh的......我想你可以問matplotlib顯示網格,組合barplot(以色列)用散點圖或直接文本繪製,對於符號(S)
實現這一目標
編輯:這可以幫助你開始。不過,需要在蜱蟲方面做一些工作。
#!/usr/bin/python
from pylab import *
import matplotlib
import matplotlib.ticker as ticker
# Setting minor ticker size to 0, globally.
# Useful for our example, but may not be what
# you want, always
matplotlib.rcParams['xtick.minor.size'] = 0
# Create a figure with just one subplot.
# 111 means "1 row, 1 column, 1st subplot"
fig = figure()
ax = fig.add_subplot(111)
# Set both X and Y limits so that matplotlib
# don't determine it's own limits using the data
ax.set_xlim(0, 800)
# Fixes the major ticks to the places we want (one every hundred units)
# and removes the labels for the majors: we're not using them!
ax.xaxis.set_major_locator(ticker.FixedLocator(range(0, 801, 100)))
ax.xaxis.set_major_formatter(ticker.NullFormatter())
# Add minor tickers AND labels for them
ax.xaxis.set_minor_locator(ticker.AutoMinorLocator(n=2))
ax.xaxis.set_minor_formatter(ticker.FixedFormatter(['AB%d' % x for x in range(1, 9)]))
ax.set_ylim(-2000,6500, auto = False)
# And set the grid!
ax.grid(True, linestyle='-')
# common attributes for the bar plots
bcommon = dict(
height = [8500], # Height = 6500 - (-2000)
bottom = -2000, # Where to put the bottom of the plot (in Y)
width = 100) # This is the width of each bar, itself
# determined by the distance between X ticks
# Now, we create one separate bar plot pear colored column
# Each bar is a rectangle specified by its bottom left corner
# (left and bottom parameters), a width and a height. Also, in
# your case, the color. Three of those parameters are fixed: height,
# bottom and width; and we set them in the "bcommon" dictionary.
# So, we call bar with those two parameters, plus an expansion of
# the dictionary.
# Note that both "left" and "height" are lists, not single values.
# That's because each barplot could (potentially) have a number of
# bars, each one with a left starting point, along with its height.
# In this case, there's only one pair left-height per barplot.
bars = [[600, 'blue'],
[700, 'orange']]
for left, clr in bars:
bar([left], color=clr, **bcommon)
show()
+1爲片段!涼!。令我驚訝的是,這樣一個簡短的片段幾乎完全實現了我在我的第一個要求中所要做的事情!現在試着瞭解你寫的東西! ...呃,請你補充一些意見,所以像我這樣的凡人可以理解代碼:)謝謝! –
那裏。我也修改了線框圖,以便每個彩色列添加更少的代碼。 –
感謝您的評論!我已經設法稍微調整一下你的代碼,讓它更多地指向我希望它發生的方向。有幾件事情我仍然需要幫助 - 例如'中心'的文本標籤爲X軸(希望容易?)和寫在由(列名,Y值)指定的座標文本。請看我更新的問題。 –