# Generate Matlab plot markers

Matlab has a useful command for visualizing data: plot. It draws data points using "markers" in 2-D space, connecting them with lines; however, for this challenge, let's ignore the lines and use only markers. In fact, only one marker.

Input: one of Matlab's marker symbols: . o x + * s d v ^ < > p h

Output: corresponding image for that marker, which is one of the following 13 icons:

To make it clearer, here are the same icons enlarged, so the pixels can be easily seen:

• Take the input as a string, a char, an integer ASCII code, or anything equivalent

• Produce the output by displaying the image, returning it as a function's return value, saving it to a file, etc

• The image should have pixels of two different colours in it. I used blue on white, because this is what Matlab uses by default, but any other colour scheme is OK, e.g. white on black.

• The image can have padding of background colour of any size

• The pixels can be enlarged by any integer ratio, e.g. instead of the original 11-by-9 image for the triangle, you can output a 110-by-72 image, in which 10-by-8 blocks represent the original pixels

• As a corollary of the above, you can output text with glyphs like █ instead of an image, if you can print this text properly (i.e. without gaps between glyphs) on the same system which runs the code

For quick reference, here are the bitmaps for each input:

• .

0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 1 1 1 0 0 0 0
0 0 0 1 1 1 1 1 0 0 0
0 0 0 0 1 1 1 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0

• o

0 0 0 0 1 1 1 0 0 0 0
0 0 1 1 0 0 0 1 1 0 0
0 0 1 0 0 0 0 0 1 0 0
0 1 0 0 0 0 0 0 0 1 0
0 1 0 0 0 0 0 0 0 1 0
0 1 0 0 0 0 0 0 0 1 0
0 0 1 0 0 0 0 0 1 0 0
0 0 1 1 0 0 0 1 1 0 0
0 0 0 0 1 1 1 0 0 0 0

• x

0 0 1 0 0 0 0 0 1 0 0
0 0 0 1 0 0 0 1 0 0 0
0 0 0 0 1 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 1 0 0 0 0
0 0 0 1 0 0 0 1 0 0 0
0 0 1 0 0 0 0 0 1 0 0

• +

0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0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bitmaps is optional. So e.g. for the . input, a 5x5 image would be sufficient.

• Possibly add compression? – Jonathan Frech Nov 11 '18 at 20:27
• Can output be unpad? (5*5 for .) – l4m2 Nov 12 '18 at 0:29
• Why is the star so horribly mutilated? ergh – Jo King Nov 12 '18 at 0:55
• I am more fascinated by the fact that it's still recognizable when the pixels are small enough! – anatolyg Nov 12 '18 at 1:00
• @JonathanFrech Rather than compression, I think kolmogorov-complexity is more appropriate due to the limited number of potential inputs and direct mapping of inputs to outputs (similar to this challenge). – user77406 Nov 13 '18 at 15:00

# Node.js, 310 bytes

Takes the ASCII code of the symbol as input.

n=>Buffer(~A<<13)$$"~"6+'?'+6"~'81<<<18'~/973202459/~"$$)31<<A~"%;3)3;%"~~ !&(=@=-#! ~""""?""""~"%>3*,:3~~"$))1<1))$"~"'.'"~?<<<<<<<?~1)$"$)1.split~[n*7%86%17]).map(c=>s+=(g=n=>n--?' █'[[...Buffer('$8$$L0,4(8(4T(!#""0(,|T8F'),290,280,34,38,1051].map(c=>p+=c-32,p=0)[c-32]>>n&1]+g(n): )(11),s='')&&s  Try it online! ### How? All symbols can be generated by combining $$\34\$$ distinct binary patterns. Each pattern is identified with a character $$\C\$$ (from space to "A"). The patterns are ordered from lowest to highest, using their decimal representation $$\N\$$. What's actually stored is the difference $$\d\$$ between two consecutive patterns, plus $$\32\$$.  ID | C | pattern | N | d | d+32 ----+-----+-------------+------+------+------ 0 |   | 00000000100 | 4 | 4 | 36 1 | ! | 00000011100 | 28 | 24 | 56 2 | " | 00000100000 | 32 | 4 | 36 3 | # | 00000100100 | 36 | 4 | 36 4 |  | 00001010000 | 80 | 44 | 76 5 | % | 00001100000 | 96 | 16 | 48 6 | & | 00001100100 | 100 | 4 | 36 7 | ' | 00001110000 | 112 | 12 | 44 8 | ( | 00010000100 | 132 | 20 | 52 9 | ) | 00010001000 | 136 | 4 | 36 10 | * | 00010010000 | 144 | 8 | 40 11 | + | 00010101000 | 168 | 24 | 56 12 | , | 00010110000 | 176 | 8 | 40 13 | - | 00011000100 | 196 | 20 | 52 14 | . | 00011111000 | 248 | 52 | 84 15 | / | 00100000000 | 256 | 8 | 40 16 | 0 | 00100000001 | 257 | 1 | 33 17 | 1 | 00100000100 | 260 | 3 | 35 18 | 2 | 00100000110 | 262 | 2 | 34 19 | 3 | 00100001000 | 264 | 2 | 34 20 | 4 | 00100011000 | 280 | 16 | 48 21 | 5 | 00100100000 | 288 | 8 | 40 22 | 6 | 00100100100 | 292 | 4 | 36 23 | 7 | 00100110000 | 304 | 12 | 44 24 | 8 | 00110001100 | 396 | 92 | 124 25 | 9 | 00111000000 | 448 | 52 | 84 26 | : | 00111011000 | 472 | 24 | 56 27 | ; | 00111011100 | 476 | 4 | 36 28 | < | 01000000010 | 514 | 38 | 70 29 | = | 01100000100 | 772 | 258 | 290 30 | > | 01111111100 | 1020 | 248 | 280 31 | ? | 01111111110 | 1022 | 2 | 34 32 | @ | 10000000100 | 1028 | 6 | 38 33 | A | 11111111111 | 2047 | 1019 | 1051  The 29 first values $$\d+32\$$ can be directly converted to ASCII characters and stored as a Buffer. The last 5 ones are stored as number literals. [...Buffer('8$$L0$,4$(8(4T(!#""0($,|T8\$F'),290,280,34,38,1051]


Using the characters $$\C\$$ defined above, we can encode each symbol as a string.

Example:

..█........     00100000000 --> '/'
..███......     00111000000 --> '9'
..█..██....     00100110000 --> '7'
..█....█...     00100001000 --> '3'
..█.....██.     00100000110 --> '2'
..█.......█ --> 00100000001 --> '0' --> '/973202459/'
..█.....██.     00100000110 --> '2'
..█...██...     00100011000 --> '4'
..█..█.....     00100100000 --> '5'
..███......     00111000000 --> '9'
..█........     00100000000 --> '/'


All symbols are stored in a single string, delimited with ~. We use a hash function to convert the input ASCII code into the position of the symbol in the list.

# Charcoal, 163154 152 bytes

≔█η≡θo«Ｇ→↘→²η‖Ｏ↘¬»d«Ｇ↘³↓²↘³η‖Ｏ¬»h«ＧＨ↖↑→→↑↗↓↘→→↙↓²η‖Ｏ↓».ＧX³ηpＧ↑²↙⁴↖²→⁸↙³↓³→²↓²↖³↙²←³↓²↗²↑³ηsＢ⁹η¿№x+*θ«Ｆ¬⁼θ+ＰX×⁴ηＦ¬⁼θxＰ+×⁵η»«ＧＨ←←←←←↘↓↘↓↘↘↓↘²η‖Ｏ⟲⊗⌕v>^<θ


Try it online! Link is to verbose version of code. Explanation:

≔█η


Get the █ character into a variable. As @ASCII-only explains, a properly encoded Charcoal file would use three bytes to express this character, so it needs to be in a variable as it gets used a lot. (But it's still 2 bytes shorter than the previous approach.)

≡θ


Use a switch statement for the six easy characters.

o«Ｇ→↘→²η‖Ｏ↘¬»


Handle the o by drawing one eighth of the figure and mirroring it three times.

d«Ｇ↘³↓²↘³η‖Ｏ¬»


Handle the d by drawing one quarter of the figure and mirroring it twice.

h«ＧＨ↖↑→→↑↗↓↘→→↙↓²η‖Ｏ↓»


Handle the h by drawing the top half and mirroring it.

.ＧX³η


Handle the . by drawing a diamond.

pＧ↑²↙⁴↖²→⁸↙³↓³→²↓²↖³↙²←³↓²↗²↑³η


Handle the p by drawing it manually.

sＢ⁹η


Handle the s by drawing a hollow rectangle. (This one is the last of the six because Box can take 3 parameters but the following ¿ isn't legal as a parameter.)

¿№x+*θ«Ｆ¬⁼θ+ＰX×⁴ηＦ¬⁼θxＰ+×⁵η»


Handle the x, + and *, the latter by overlapping the former.

«ＧＨ←←←←←↘↓↘↓↘↘↓↘²η‖Ｏ⟲⊗⌕v>^<θ


Draw the left half of the v, then mirror it, then rotate it if the character happens to be >, ^ or <.

• Wait, doesn't handle it correctly? – ASCII-only Nov 18 '18 at 5:01
• @ASCII-only: well, that character isn't in Charcoal's code page, so it can't really appear in the source, can it? – Neil Nov 18 '18 at 18:03
• If you check it, it's counted as... 3? bytes. I'm not sure if it actually works, but it should - Charcoal should have rudimentary Unicode translation for a certain number of characters after a 0xFF. I'll check later and link if it works – ASCII-only Nov 18 '18 at 21:45
• here – ASCII-only Nov 18 '18 at 21:52
• @ASCII-only Ah, I didn't know that about the 0xFF byte. It's a bit confusing because the bytes that the encoded file would need correspond to �﹪⧴ in Charcoal's code page but TIO works in Unicode characters so you can't easily demonstrate that. – Neil Nov 19 '18 at 0:20

# MATL, 9 bytes

1w&XG7lZG


Cheating? Maybe. Try it on MATL Online.

Literal translation of the MATLAB code plot(1,input(''));axis off (26 bytes). The online version compresses the image, but on a local machine it will simply use the MATLAB plot defaults.

• I guess the consensus is that built-in functions are allowed by default, so no cheating. – anatolyg Nov 12 '18 at 11:11
• @anatolyg I know, else I wouldn't have posted it. But it definitely feels like cheating ;) – Sanchises Nov 12 '18 at 11:51

# Python, 58 bytes

from matplotlib.pyplot import*
plot(0,input())
axis('off')


Fun to take advantage of matplotlib doing all the heavy lifting.