mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-05-05 22:31:11 +08:00
Fix xlim and ylim
This commit is contained in:
parent
c9513e463f
commit
a8ce96888e
@ -90,6 +90,7 @@ module YouPlot
|
||||
params.name ||= headers[1]
|
||||
params.xlabel ||= headers[0]
|
||||
end
|
||||
params.xlim ||= series[0].flatten.minmax # why need?
|
||||
params.ylim ||= series[1..-1].flatten.minmax # why need?
|
||||
plot = UnicodePlot.public_send(method1, series[0], series[1], **params.to_hc)
|
||||
2.upto(series.size - 1) do |i|
|
||||
@ -103,13 +104,14 @@ module YouPlot
|
||||
series = data.series
|
||||
method2 = get_method2(method1)
|
||||
series.map! { |s| s.map(&:to_f) }
|
||||
series = series.each_slice(2).to_a
|
||||
series2 = series.each_slice(2).to_a
|
||||
series = nil
|
||||
params.name ||= headers[0] if headers
|
||||
params.xlim = series.map(&:first).flatten.minmax # why need?
|
||||
params.ylim = series.map(&:last).flatten.minmax # why need?
|
||||
params.xlim ||= series2.map(&:first).flatten.minmax # why need?
|
||||
params.ylim ||= series2.map(&:last).flatten.minmax # why need?
|
||||
x1, y1 = series.shift
|
||||
plot = UnicodePlot.public_send(method1, x1, y1, **params.to_hc)
|
||||
series.each_with_index do |(xi, yi), i|
|
||||
series2.each_with_index do |(xi, yi), i|
|
||||
UnicodePlot.public_send(method2, plot, xi, yi, name: headers&.[]((i + 1) * 2))
|
||||
end
|
||||
plot
|
||||
|
26
test/fixtures/iris-density.txt
vendored
26
test/fixtures/iris-density.txt
vendored
@ -1,20 +1,20 @@
|
||||
IRIS-DENSITY
|
||||
┌────────────────────────────────────────┐
|
||||
6.9 │ │ sepal_width
|
||||
6.9 │ ░ │ sepal_width
|
||||
│ │ petal_length
|
||||
│ │ petal_width
|
||||
│ │ species
|
||||
│ ░ │
|
||||
│ │
|
||||
│ ░ │ petal_width
|
||||
│ ░ ░░ │ species
|
||||
│ ░ ░ │
|
||||
│ ░ │
|
||||
│ ░ │
|
||||
│ ░ ░ ░░ ░ │
|
||||
│ ░ ░ ░ │
|
||||
│ ░ ░░ ░ │
|
||||
│ ▒░ ░ │
|
||||
│ ░ ░░ ░░ ░ ░ ░░ ░░░ │
|
||||
│ ░ ░ ░ ░ │
|
||||
│ ░░ ░ ░ │
|
||||
│ ░ ░░░▒ ░ ░ ░░░ ░ ░ │
|
||||
│ ░ ░░░░ │
|
||||
│ │
|
||||
│ ░ ░▒ ░ ░ ░ ░ │
|
||||
│ ░ ░ ░ │
|
||||
│ │
|
||||
0 │ ░░ ▒ ░█ ░ ░▒ ░░ ░ ░░░ ░ │
|
||||
0 │ ░ ▒░▒▒██ ▒ ▓▒░▒▒░░░ ░▒▒░ ▒░░ ░ ░ │
|
||||
└────────────────────────────────────────┘
|
||||
4 8
|
||||
4.3 7.9
|
||||
sepal_length
|
||||
|
32
test/fixtures/iris-lineplots.txt
vendored
32
test/fixtures/iris-lineplots.txt
vendored
@ -1,20 +1,20 @@
|
||||
IRIS-LINEPLOTS
|
||||
┌────────────────────────────────────────┐
|
||||
6.9 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣲⠭⠃⠀⠀│ sepal_width
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⠀⢀⣀⣠⣤⣶⣿⣿⣯⣴⣒⠖⠉⠁│ petal_length
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⢮⣤⣤⣶⣿⣿⣿⠿⠛⠛⠋⠉⠀⠀⠀⠀⠀⠀│ petal_width
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣴⣷⣿⣿⣿⣿⣿⣿⣟⣟⡂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ species
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⠤⠔⠒⢙⡻⠝⢋⡽⢝⣳⣾⣫⣥⣒⣪⣵⣖⣂⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠁⠀⠀⢀⣉⣟⣻⣿⣻⣿⣿⣿⠿⣿⣿⠿⠟⡢⠒⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣤⣿⣷⣾⣿⡿⣿⡯⠿⠛⠋⠉⠀⣀⠔⠉⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣄⣀⠄│
|
||||
│⠀⠀⠀⠀⢀⣨⣽⣿⣿⣿⣿⣿⣿⣿⣵⣚⣉⣃⣀⣠⣤⣤⣔⣮⣤⣄⣀⣠⣤⣔⣲⣾⡳⠮⠛⠋⢉⡗⠁⠀│
|
||||
│⠀⠀⠐⠒⡿⠿⠟⡻⠛⠛⠛⠚⠉⠀⠲⣶⣿⣷⣾⣷⣿⣿⣷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣶⣷⡇⠀⠀│
|
||||
│⠀⠀⠀⠀⢱⡠⠊⠀⠀⣤⣤⣶⣿⣿⠿⣿⣿⣿⣿⣿⣟⣿⣿⣟⣟⣉⣉⣝⣛⣫⣭⣥⣤⣤⣔⣒⣒⡃⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠁⠀⢀⡀⠀⢯⠒⠉⡠⠔⠡⠤⠮⣤⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣶⣶⣶⣶⣿⣿⠥⠤⠄│
|
||||
│⠀⠀⠀⠀⣀⣠⣄⣤⣭⣿⣿⣿⣿⣿⣿⣿⣿⣯⣯⣯⣭⣽⣿⣿⣿⣿⣿⣯⣭⣍⡙⠛⠝⠉⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠠⠴⠿⢯⠭⠿⠯⣭⣷⡾⠿⠿⠿⣿⢿⡿⡻⠿⡟⠛⢛⣛⠯⠭⠒⠒⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣄⠀⠀⠀⢀⣀⡠⠤⠔⠒⠊⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
0 │⠀⠀⢀⣀⣴⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣻⣷⣄⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⡀│
|
||||
6.9 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣴⡮⠟⠀⠀│ sepal_width
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⣀⣀⣤⣴⣶⣿⣟⣯⣥⣔⣲⠊⠉│ petal_length
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣔⢾⣥⣤⣶⣿⣿⣿⣿⠿⠛⠛⠋⠉⠀⠀⠀⠀⠀⠀│ petal_width
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣛⣗⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ species
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⠤⠔⠒⣋⡻⠭⠛⣩⡿⣟⣷⣽⣫⣥⣒⣲⣭⣶⣒⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠀⠈⠉⠀⠀⠀⢀⣉⡟⣛⣿⣝⣻⣿⣿⣿⠿⢿⣿⡿⠿⣛⠤⠊⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠀⠀⢀⣠⣤⣿⣷⣿⣿⣿⣿⣿⠿⠿⠛⠋⠉⠁⣀⠔⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣠⢀⣠│
|
||||
│⠀⢀⣀⣭⣿⣿⣿⣿⣿⣿⣿⣿⣽⣖⣋⣙⣀⣀⣤⣤⣤⣔⣮⣤⣄⣀⣀⣤⣤⣔⣶⣾⡳⠮⠝⠓⢊⢽⠋⠀│
|
||||
│⠒⢷⠿⠿⢛⠟⠛⠙⠑⠚⠉⠀⠲⣶⣿⣿⣶⣿⣷⣿⣿⣷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣶⣷⣾⠀⠀│
|
||||
│⠀⠸⡠⠔⠁⠀⢠⡤⣴⣶⣿⣿⠿⣿⣿⣿⢿⣿⣿⣿⣿⣿⣟⣟⣉⣉⣩⣛⣛⣭⣭⣥⣤⣤⣔⣒⣒⡚⠀⠀│
|
||||
│⠀⠀⠁⠀⠀⢀⡀⠨⢞⠊⢉⡠⠔⠉⠤⠴⢥⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣷⣶⣶⣶⣶⣿⣿⡭⠤⠤│
|
||||
│⠀⣀⣀⣄⣤⣤⣽⣿⣿⣿⣿⣿⣿⡿⣿⣿⣽⣽⣯⣭⣿⣿⣿⣿⣿⣿⣿⣭⣭⣉⠛⠛⠝⠉⠀⠀⠀⠀⠀⠀│
|
||||
│⠤⠿⠿⡯⠽⠿⢭⣽⣶⡾⠿⠿⠿⣿⠿⣿⢟⠿⢻⠟⠛⣛⣛⠯⠭⠝⠒⠊⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⢀⣀⡠⣀⠀⠀⠀⢀⣀⡠⠤⠤⠒⠒⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
0 │⣀⣴⣶⣾⣿⣷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀│
|
||||
└────────────────────────────────────────┘
|
||||
4 8
|
||||
4.3 7.9
|
||||
sepal_length
|
||||
|
32
test/fixtures/iris-scatter.txt
vendored
32
test/fixtures/iris-scatter.txt
vendored
@ -1,20 +1,20 @@
|
||||
IRIS-SCATTER
|
||||
┌────────────────────────────────────────┐
|
||||
6.9 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠃⠀⠀│ sepal_width
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠂⠄⠀⠀⠄⠀⠁│ petal_length
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⡀⡀⠂⠀⡆⠁⠄⠈⠀⠂⠀⠀⠀⠀⠀⠀⠀│ petal_width
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⡀⡀⠀⠂⡀⠃⡅⠀⠄⠁⡂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ species
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠁⠀⠄⢕⠀⠄⡃⠀⠀⠀⡁⠄⠂⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠁⣊⠀⡃⠀⡀⠉⠀⠅⠂⠅⠙⠀⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠀⢅⠀⡄⡮⠀⠅⠇⠀⠒⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠄│
|
||||
│⠀⠀⠀⠀⠀⠨⠀⠠⠀⡀⣷⠀⠆⠀⠄⠊⠀⠂⠀⠀⠄⠀⠄⡄⠀⠀⠀⡀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠐⠀⠇⠘⠀⠑⠀⠂⠓⠀⠀⠀⠂⢰⠀⡆⡀⠃⢶⠀⡄⡄⡇⡳⠀⠂⡃⠃⠑⠀⠃⠄⡀⠀⠂⡂⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠠⠀⠁⠀⠀⡮⠀⠆⡃⠀⠑⠀⠀⡅⠁⠀⠀⡄⠀⠀⠀⠀⠄⠀⠀⠀⠀⠂⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠁⠀⢀⠀⠀⢅⠀⠀⠀⠀⠡⠀⠄⡀⠀⠁⠀⠁⡁⡃⠅⠀⠃⠃⠃⠐⠀⠀⠀⡀⠀⠂⠅⠀⠄│
|
||||
│⠀⠀⠀⠀⡀⢠⠀⢤⠀⡆⣴⠀⡤⠀⠆⡠⠀⠆⠀⠅⢍⠀⠅⠅⠅⢅⠀⡇⡀⠄⡀⠀⠅⠁⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠠⠀⠁⢁⠀⠁⠀⡀⡣⠀⠀⠀⠁⡯⠀⡃⡂⠀⡘⠀⠁⠁⠁⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
0 │⠀⠀⢀⠀⡄⣲⠀⣴⠀⡄⣿⠀⣤⠀⡅⣄⠀⡃⡄⡀⣀⠀⡀⡀⡀⣀⠀⡀⡀⡀⣀⠀⡀⡀⡀⠀⡀⡀⠀⡀│
|
||||
6.9 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠘⠀⠀│ sepal_width
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠂⠄⠀⠀⠠⠀⠈│ petal_length
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⡀⡀⠂⠀⢰⠈⠠⠀⠀⠁⠂⠀⠀⠀⠀⠀⠀⠀│ petal_width
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⢀⢀⠀⠀⠂⡀⠃⡅⠀⠠⠈⢐⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ species
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠈⠀⠠⠨⢐⠀⠄⡃⠀⠀⠀⢈⠠⠐⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠁⡂⡁⢘⠀⢀⠈⠈⠀⠅⠂⠅⠁⠘⠐⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠀⢠⠀⠅⡀⡄⡆⠅⠨⠸⠀⠐⠐⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠠│
|
||||
│⠀⠀⠀⠅⠀⠠⢀⢸⢰⠀⠆⠀⠄⠂⠁⠐⠀⠀⠠⠀⠀⠄⡄⠀⠀⠀⢀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠂⠇⠀⠃⠁⠐⠐⠘⠐⠀⠀⠀⠂⠀⡆⢰⢀⠘⠰⢰⠀⡄⡄⡇⡃⠰⠐⢘⠘⠈⠀⠂⠃⠄⡀⠀⠐⢐⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠀⢠⠀⠠⠀⠁⠀⠀⡆⠅⠰⢘⠀⠈⠐⠀⠀⡅⠁⠀⠀⢠⠀⠀⠀⠀⠀⠄⠀⠀⠀⠀⠐⠀⠀│
|
||||
│⠀⠀⠁⠀⠀⢀⠀⠨⢀⠀⠀⠀⠀⠁⠄⠠⢀⠀⠈⠀⠀⠁⡁⡃⠅⠀⠘⠘⠘⠀⠀⠂⠀⠀⡀⠀⠐⠨⠀⠠│
|
||||
│⠀⡀⠀⡄⠄⢠⢰⢠⢰⠀⡄⠄⠆⡀⠄⠰⠀⠨⠨⢈⠀⠅⠅⠅⠅⢀⢸⢀⠠⢀⠀⠀⠅⠁⠀⠀⠀⠀⠀⠀│
|
||||
│⠄⠁⠁⡀⠁⠀⢀⢘⠠⠀⠀⠀⠁⡇⠅⢘⢐⠀⢀⠘⠀⠁⠁⠁⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
│⠀⠀⠀⠀⠀⠀⠀⠠⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
|
||||
0 │⡀⡄⡂⡆⡄⢰⢠⢸⢸⠀⡄⡄⡅⡄⡀⢘⢠⢀⢀⢀⠀⡀⡀⡀⡀⢀⢀⢀⢀⢀⠀⡀⡀⡀⡀⠀⢀⢀⠀⢀│
|
||||
└────────────────────────────────────────┘
|
||||
4 8
|
||||
4.3 7.9
|
||||
sepal_length
|
||||
|
Loading…
Reference in New Issue
Block a user