Markus Weninger
Markus Weninger

Reputation: 12648

Gnuplot: Convert integer to ASCII value

I would like to generate multiple plots within one gnuplot script, and would like to start each plot's title with a running capital letter, i.e., the first plot will have the title (A) sample title for first chart, the second one (B) sample title for second chart, and so on.

In Java, for this I basically have to do

int i = 65;       // ASCII value for 65
char c = (char)i; // Convert 65 to corresponding ASCII value ('A')
i++;
// Use c; then repeat

I just tried something similar in gnuplot by using gprintf and using the %c formatter, yet I could not get it working due to the problem

These format specifiers are not the same as those used by the standard C-language routine sprintf().

Long question short: How to convert an integer to its corresponding ASCII value?

Upvotes: 1

Views: 565

Answers (1)

matt
matt

Reputation: 12347

gnuplot> print sprintf("%c", 65)
#A

Gnuplot provides a gprintf which uses gnuplot format specifiers and sprintf.

Upvotes: 3

Related Questions