From: Kevin K. <kk...@gm...> - 2016-10-26 04:40:38
|
It is not completely clear to me how to use utf-8 symbols in my plots. Through web searching I have determined the following: 1. I need to use an enhanced output format 2. I need to set character encoding to utf-8 3. I need to ensure the gnuplot command file itself is in utf-8 Given the above, here are the commands I am using for 1. and 2.: set term png size 1600x1200 enhanced set encoding utf-8 Here is the linux command I use for part 3: iconv -f iso-8859-1 -t utf-8 -o <utf-8_file> <original_file> I want to use greek characters in my xlabels. Every example I find online says to simply copy the greek character from somewhere else and directly paste it into my gnuplot command file. The problem I have is that the text editor I am using (Nedit) does not seem to support these symbols and they appear as '?' when I try to paste them from somewhere else. This then produces a '?' character in my plot. Is there a way to specify the character using its hex code? For example, the lowercase Greek 'mu' has code 0x3BC. I tried using all of the following to reference this character: 03BC "03BC" "U+03BC" "\UO3BC" "\u03BC" But all of these strings end up being interpreted literally and do not produce a 'mu' character. Is there some specific syntax I can use to display a unicode character using its hex code? |
From: Ethan A M. <eam...@gm...> - 2016-10-26 06:32:04
|
On Tuesday, 25 October 2016 11:40:30 PM Kevin Klein wrote: > It is not completely clear to me how to use utf-8 symbols in my plots. > Through web searching I have determined the following: > > > > 1. I need to use an enhanced output format No. The encoding is separate from the enhanced mark-up, if any. > 2. I need to set character encoding to utf-8 Yes. > 3. I need to ensure the gnuplot command file itself is in utf-8 You need to make sure that the character strings to be printed are in utf-8 encoding. Normally that means the rest of the file is also in utf-8, but strictly speaking that isn't necessary. > > > Given the above, here are the commands I am using for 1. and 2.: > > > > set term png size 1600x1200 enhanced > > set encoding utf-8 > > > > Here is the linux command I use for part 3: > > > > iconv -f iso-8859-1 -t utf-8 -o <utf-8_file> <original_file> That step would only be necessary if your file already contains non-ascii characters that are in iso-8859-1 encoding. For normal text files this is not the case. Is your linux environment not already in utf-8? That has been the linux default for a long time now. > I want to use greek characters in my xlabels. Every example I find online > says to simply copy the greek character from somewhere else and directly > paste it into my gnuplot command file. That would work, so long as the program you are copying them from is also running in a utf-8 environment. I normally use kcharselect for this (standard KDE utility) but I'm sure many other tools work as well. > The problem I have is that the text editor I am using (Nedit) does not seem > to support these symbols and they appear as '?' when I try to paste them > from somewhere else. This then produces a '?' character in my plot. A bit of Googling seems to indicate that nedit does not support utf-8. How very antiquated. If that is so, I seriously suggest that you should switch to an editor that does, even at the cost of short-term pain as you relearn a few tricks. Nevertheless, if the byte-sequence you paste into it is correctly encoded in utf-8 it will be properly handled by gnuplot even though your editor shows only ?? instead of the desired symbol. But this is obviously not ideal as you will be working blind. > > > Is there a way to specify the character using its hex code? For example, > the lowercase Greek 'mu' has code 0x3BC. I tried using all of the > following to reference this character: > > > > 03BC > "03BC" > "U+03BC" > "\UO3BC" > "\u03BC" > > But all of these strings end up being interpreted literally and do not > produce a 'mu' character. Is there some specific syntax I can use to > display a unicode character using its hex code? Not inside gnuplot. But something equivalent to that is usually provided by the operating environment itself. It really depends on how your system is configured. For example if you have "Greek dead-key" mode enabled for your keyboard input, then typing <greek><m><m> should get you a greek character mu. Also most editors (although apparently not Nedit) support something of this sort. For example in the vim editor it is <ctrl-v>U03BC. Ethan -- |