In this code-golf challenge, you are provided with a series of y values at even x-values as well as a console width and height. The desired output is an ASCII-art representation of a ribbon plot of the y-values scaled to the desired size. If all values are positive or negative, the x-axis should be displayed at the bottom or top respectively. Otherwise, the x-axis should be displayed at the appropriate position with the graph extending to the top and bottom.
The data should be scaled horizontally by splitting the data into sublists of equal (+/- 1) size and taking the arithmetic mean of each sublist. There will never be fewer values than columns, but can be more.
Inspired by this question which was posed as a tips in C question. Most similar question is here but there are some important differences in terms of input (floats versus equation) and output style.
Input/output
- Default I/O rules apply.
- Default loopholes forbidden.
- The y-values will be a list, array or equivalent of floating point numbers at least as long as the width of the console. These may be positive or negative. Choice of float type is at the discretion of the answerer. Y values should be rounded to the nearest integer after scaling to the relevant size; the default rounding method for 0.5s supported by the language is fine (rounding to even, rounding away from zero, etc.) (See Wikipedia for a discussion of different rounding methods if this is an unfamiliar topic.) However, truncation/floor/ceiling are not permitted approaches.
- The range of y values will always be non-zero (i.e. there will be more than 1 y value, and there will be at least 2 different values).
- The console width and height will be two integers, with the height always at least 2.
- The output can be a return value or be output to STDOUT. If opting for a return value, this can be a single newline-separated string, a list of strings, a list of lists of characters or a matrix of characters.
- Any distinct character can be chosen for the filled area, but the blank area should be a space character.
- A separate non-space character should be used to indicate the x-axis.
- Trailing space on each line is optional.
Worked example of how the data is scaled to width
Floats: 1.0,2.0,3.0,4.0,5.0
Width: 3
Split into three pieces: [1,2],[3,4],[5]
Take arithmetic mean of each: [1.5,3.5,5]
Examples of full input/output
Input
Floats: [1.4330127018922192, 1.4740546219716173, 1.46726631732171, 1.4118917879852302, 1.3095749615197134, 1.1642846441770978, 0.98209964435211, 0.770867389064186, 0.5397574401179837, 0.29873801741462563, 0.05800851721072442, -0.17257624372014382, -0.38405389828888165, -0.5688402657187754, -0.7211228325469043, -0.8371379250265838, -0.915315134687127, -0.9562812209887335, -0.9627248583907679, -0.939132622452629, -0.8914149315594007, -0.8264477348143321, -0.7515611018951998, -0.6740091786833334, -0.6004570095761375, -0.5365184287338843, -0.48637567624364625, -0.45250583664959154, -0.4355319935803172, -0.43420862005149424, -0.445541730745404, -0.46503530191616943, -0.4870470099638535, -0.5052290073886498, -0.5130237273726901, -0.5041809629881258, -0.47326095136808916, -0.41608900827923856, -0.330130352731954, -0.21475893339455088, -0.07140098112303239, 0.09645778693148394, 0.28340343297327375, 0.4823565362517651, 0.6849507176587676, 0.8820035800170399, 1.0640505126834876, 1.2219075413197402, 1.3472273300168627, 1.433012701892219]
Width: 24
Height: 24
Output:
#
# #
## #
## ##
## ##
## ##
### ##
### ###
### ###
### ###
#### ####
#### ####
#### ####
#### ####
------------------------
###############
##############
##############
#############
####### ##
#####
#####
###
##
Input
Floats: [0.5, 3, 7.5, 14, 22.5, 33, 45.5, 60, 76.5, 95, 115.5, 138, 162.5, 189, 217.5, 248, 280.5, 315, 351.5, 390, 430.5, 473, 517.5, 564, 612.5, 663, 715.5, 770, 826.5, 885, 945.5, 1008, 1072.5, 1139, 1207.5, 1278, 1350.5, 1425, 1501.5, 1580, 1660.5, 1743, 1827.5, 1914, 2002.5, 2093, 2185.5, 2280, 2376.5, 2475]
Width: 24
Height: 24
Output
#
#
##
##
###
####
####
#####
######
######
#######
########
#########
#########
##########
###########
############
#############
##############
################
#################
###################
######################
------------------------
Input
Floats: [-4.0,0.0,0.0,4.0,2.0]
Width: 5
Height: 5
Output
#
##
-----
#
#
Input
Floats: [0.0,1.0,2.0,3.0]
Width: 4
Height: 4
Output
#
##
###
----
œsÆm€
where the left argument is the floats and the right argument the width. \$\endgroup\$