-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Issue
When I plot three different charts with identical y data, but transpose the x range, the x labels are incorrect, and the displayed ranges differ.
To reproduce
require 'unicode_plot'
def plot_sine_for_year(year)
start_date = Date.new(year, 1, 1)
x = (0..364).map { |i| start_date + i }
y_sin = x.map { |xi| Math.sin((xi - start_date).to_f / 30 * 2 * Math::PI) }
plot = UnicodePlot.lineplot(x, y_sin, name: "sin(x)", width: 40, height: 5, title: year.to_s)
plot.render
end
[2020, 2021, 2022].each { |year| plot_sine_for_year(year) }
Expected behaviour
The x ranges start and finish at the same point relative to the first datapoint
OR
The x labels are the actual labels for the starting point of the axis, rather than the beginning and end of the range
Actual behaviour
The scales are all different
- There is more padding to the left of the 2021 example than the 2020 example.
- The 2021 example is much more "compressed" than 2020
- However, the start and end of the xrange (labels) imply that they are the same scale, spanning the full set
2020
┌────────────────────────────────────────┐
1 │⠀⠀⢀⢿⠀⢀⢿⠀⢀⢿⠀⢀⢿⠀⢀⢿⠀⢀⢿⠀⢀⢿⠀⢀⢿⠀⢀⢿⠀⢀⢿⠀⢀⢿⠀⢀⢿⠀⢀⠀│ sin(x)
│⠀⠀⢸⠸⡀⢸⠸⡀⢸⠸⡀⢸⠸⡀⢸⠸⡀⢸⠸⡀⢸⠸⡀⢸⠸⡀⢸⠸⡀⢸⠸⡀⢸⠸⡀⢸⠸⡀⢸⠀│
│⠤⠤⠼⠤⡧⢼⠤⡧⢼⠤⡧⢼⠤⡧⢼⠤⡧⢼⠤⡧⢼⠤⡧⢼⠤⡧⢼⠤⡧⢼⠤⡧⢼⠤⡧⢼⠤⡧⢼⠤│
│⠀⠀⠀⠀⡇⡎⠀⡇⡎⠀⡇⡎⠀⡇⡎⠀⡇⡎⠀⡇⡎⠀⡇⡎⠀⡇⡎⠀⡇⡎⠀⡇⡎⠀⡇⡎⠀⡇⡎⠀│
-1 │⠀⠀⠀⠀⢱⡇⠀⢱⡇⠀⢱⡇⠀⢱⡇⠀⢱⡇⠀⢱⡇⠀⢱⡇⠀⢱⡇⠀⢱⡇⠀⢱⡇⠀⢱⡇⠀⢱⡇⠀│
└────────────────────────────────────────┘
2020-01-01 2020-12-30
2021
┌────────────────────────────────────────┐
1 │⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⣷⠀⡜⡄⢰⡇⠀⣿⠀⢸⡇⠀⣷⠀⡜⡄⢰⡇⠀⣿⠀⢸⡇⠀⣷⠀⡀⠀⠀⠀│ sin(x)
│⠀⠀⠀⠀⠀⠀⠀⡜⡇⢸⢹⠀⡇⡇⢸⢸⠀⡟⡆⡜⡇⢸⢹⠀⡇⡇⢸⢸⠀⡟⡆⡜⡇⢸⢹⠀⡇⠀⠀⠀│
│⠤⠤⠤⠤⠤⠤⠤⠧⢼⢼⠼⡤⡧⡧⢼⢼⢴⠥⡧⡧⢼⢼⢼⠤⡧⡧⢼⢼⢴⠥⡧⡧⢼⢼⠼⡤⡧⠤⠤⠤│
│⠀⠀⠀⠀⠀⠀⠀⠀⢸⢸⠀⣧⠇⢣⡇⢸⣸⠀⡇⡇⢸⢸⠀⣧⠇⢣⡇⢸⣸⠀⡇⡇⢸⢸⠀⣧⠇⠀⠀⠀│
-1 │⠀⠀⠀⠀⠀⠀⠀⠀⠸⡇⠀⣿⠀⢸⡇⠀⡿⠀⢣⠃⠸⡇⠀⣿⠀⢸⡇⠀⡿⠀⢣⠃⠸⡇⠀⣿⠀⠀⠀⠀│
└────────────────────────────────────────┘
2021-01-01 2021-12-31
2022
┌────────────────────────────────────────┐
1 │⠀⠀⠀⠀⢰⡇⠀⣿⠀⢸⡇⠀⣷⠀⡜⡄⢰⡇⠀⣿⠀⢸⡇⠀⣷⠀⡜⡄⢰⡇⠀⣿⠀⢀⠀⠀⠀⠀⠀⠀│ sin(x)
│⠀⠀⠀⠀⢸⢸⠀⡟⡆⡜⡇⢸⢹⠀⡇⡇⢸⢸⠀⡟⡆⡜⡇⢸⢹⠀⡇⡇⢸⢸⠀⡟⡆⡜⠀⠀⠀⠀⠀⠀│
│⠤⠤⠤⠤⠼⢼⢴⠥⡧⡧⢼⢼⠼⡤⡧⡧⢼⢼⢴⠥⡧⡧⢼⢼⢼⠤⡧⡧⢼⢼⢴⠥⡧⡧⠤⠤⠤⠤⠤⠤│
│⠀⠀⠀⠀⠀⢸⣸⠀⡇⡇⢸⢸⠀⣧⠇⢣⡇⢸⣸⠀⡇⡇⢸⢸⠀⣧⠇⢣⡇⢸⣸⠀⡇⡇⠀⠀⠀⠀⠀⠀│
-1 │⠀⠀⠀⠀⠀⠀⡿⠀⢣⠃⠸⡇⠀⣿⠀⢸⡇⠀⡿⠀⢣⠃⠸⡇⠀⣿⠀⢸⡇⠀⡿⠀⢣⠃⠀⠀⠀⠀⠀⠀│
└────────────────────────────────────────┘
2022-01-01 2022-12-31
Metadata
Metadata
Assignees
Labels
No labels