Python 让绘图条轴正确吗?

Python 让绘图条轴正确吗?,python,ggplot2,python-ggplot,Python,Ggplot2,Python Ggplot,我想使用ggplot在条形图中绘制掷骰子的结果 import numpy import ggplot import pandas frame = pandas.DataFrame() for i in range(6): frame.loc[i, 'pips'] = i+1 rand = numpy.random.random_integers(1, 6, 100) for i in range(len(count)): frame.loc[i, 'events'] =

我想使用ggplot在条形图中绘制掷骰子的结果

import numpy
import ggplot
import pandas

frame = pandas.DataFrame()

for i in range(6):
    frame.loc[i, 'pips'] = i+1

rand = numpy.random.random_integers(1, 6, 100)

for i in range(len(count)):
    frame.loc[i, 'events'] = numpy.sum(rand == i+1)

frame['propability'] = frame.events / frame.events.sum()

ggplot.ggplot(ggplot.aes(x='pips', weight='events'), frame) + ggplot.geom_bar()
结果是

从这些例子中,我希望情节能

  • 在每一条上有更多的宽度
  • 没有x=7且无杆
  • 如何解决这两个问题?

    使用参数“binwidth”、“limits”和“breaks”,如下所示:

     ggplot.ggplot(ggplot.aes(x='pips', weight='events'), frame) +
     ggplot.geom_bar(binwidth=1) +
     ggplot.scale_x_continuous(limits = (1,6), breaks = range(1,7))
    
    这给了我:


    谢谢您的回答!对于
    python3
    I需要将
    xrange(1,7)
    更改为
    range(1,7)