小编Gar*_*ant的帖子

Matplotlib - x 轴与日期时间之间的不均匀间隔

我目前遇到一个问题,当DatetimeIndex我的 x 轴使用 a 时,我的绘图上的刻度之间的空间似乎有不均匀的间隔。代码如下:

x = pd.date_range('2018-11-03', '2018-12-30')
plt.plot(x, np.arange(len(x)))
plt.xticks(rotation=45)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

请注意日期不按典型 7 天周期递增的两个实例。即使在延长时间段后,问题仍然存在:

x = pd.date_range('2018-11-03', '2019-03-20')
plt.plot(x, np.arange(len(x)))
plt.xticks(rotation=45)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

如何覆盖此行为以在我的情节上具有标准的 7 天间隔?谢谢你。

python datetime matplotlib pandas

4
推荐指数
1
解决办法
5038
查看次数

Ruby中的if语句冲突

我尝试在支持Ruby 1.8.7的在线IDE中运行此代码,并且该elsif语句未被识别; 例如,如果我输入"85",它仍然会返回"超重".

def prompt
 print ">> "
end

puts "Welcome to the Weight-Calc 3000! Enter your weight below!"

prompt; weight = gets.chomp()

if weight > "300" 
 puts "Over-weight"
elsif weight < "100"
 puts "Under-weight"
end
Run Code Online (Sandbox Code Playgroud)

但是,当我运行以下操作时,它可以正常工作:

def prompt
 print ">> "
end

puts "Welcome to the Weight-Calc 3000! Enter your weight below!"

prompt; weight = gets.chomp()

if weight > "300" 
 puts "Over-weight"
elsif weight > "100" && weight < "301"
 puts "You're good."
end
Run Code Online (Sandbox Code Playgroud)

关于如何解决这个问题的任何想法?

ruby ide if-statement puts ruby-1.8.7

1
推荐指数
2
解决办法
253
查看次数

标签 统计

datetime ×1

ide ×1

if-statement ×1

matplotlib ×1

pandas ×1

puts ×1

python ×1

ruby ×1

ruby-1.8.7 ×1