也许是matplotlib /季节性轴范围的错误?

时间:2018-08-14 11:29:38

标签: python matplotlib seaborn

potato_season <- data.frame(
    crop = c("potato", "yam"),
    start = c("January", "March"),
    end = c("August", "October"),
    y_pos = c(20000, 24000)
)
library(ggplot2)
ggplot(input2, aes(x=as.factor(key), y=value, color=as.factor(variable))) +

    geom_rect(data = potato_season, inherit.aes = F,
              aes(xmin = start, xmax = end,
                  ymin = y_pos - 2000, ymax = y_pos + 2000,
                  fill = crop)) +
    geom_text(data = potato_season, inherit.aes = F,
              aes(label = crop, y = y_pos, x = start),
              hjust = -1) + # to shift the text right

    geom_point(aes(size=value)) +
    scale_x_discrete(limits=c("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")) +
    scale_colour_manual(values=c("#CC6600", "#999999", "#FFCC33")) +
    ggtitle("Number of Images per month\n") +
    labs(x="Month",y="Number of images", fill="Legend")

enter image description here

这个错误让我感到困惑!上次它是可运行的,现在我不能更改y范围。一旦我删除了plt.ylim,一切都很好。我已经检查了所有详细信息,但找不到解决方案。我现在无法在python中更改任何数字的y范围。...但是xlimit可以正常工作,很奇怪...

1 个答案:

答案 0 :(得分:0)

在您未在此处显示的代码中,您已经写了类似plt.ylim = (0,1)之类的内容。从这一点开始,plt.ylim不再是一个函数,而是一个元组。

由于您已覆盖pyplot的ylim函数,因此需要重新启动IPython(内核)。