How to set comma as ytics separator on gnuplot - formatting

NOTE: I have read the "set decimalsign lcale" in the manual - which
seems the usual advice.
However, that deals with changing the the usual English decimal point, not adding a thousands separator.
I would like to display my ytics as "2,000,000"
How can I achieve this?

gnuplot uses the standard C-style formatting for its tic labels, so there isn't really a good way to do this automatically. If you know where you want the tics you can specify them manually, e.g.:
set ytics ("0" 0, "1,000,000" 1e6, "2,000,000" 2e6)
You can type ? set xtics for more info.
If you want to do it automatically, there may be a way to write a gnuplot function implementing something like the solution here, but that may be more trouble than it is worth.

Related

Latex escaping in MatPlotlib

There are a number of situations where it is useful to set matplotlib.rcParams['text.usetex'] = True. In this case, special LaTeX characters such as % have to be escaped in places like axis labels. Is there a function built in to matplotlib for escaping LaTeX symbols?
There is a hint of such a thing in the docs here and here, but no clear mention.
The specific problem I am trying to tackle is using a matplotlib.ticker.PercentFormatter, where a custom symbol (symbol=r'\%') must be used if rcParams['text.usetex'] is true. I am trying to add a PR that will escape the percent symbol in PercentFormatter if rcParams['text.usetex'] is enabled, but it does not make sense to only check for the percent symbol in that case, so I would like to escape the entire symbol string.

Make all text in pdf slightly thicker/fatter. Like simulating dot-gain in offset printing?

I would like to make all text in a pdf (from a customer) slightly thicker/fatter to simulate how it will look when printed (normal dot-gain) in a offset press.
If I use the PitStop-plugin in Acrobat I can convert all text to outline and then add a stroke to the outline so that it will be thicker/fatter.
However, those are manual steps and I need to automate it completely.
My thought was to go with GhostScript and I've managed to convert it to outline, but I cant find if there's a way to add stroke or something similar within GhostScript?
My current command is:
gs -o output.pdf -dNoOutputFonts -StrokeWidth=2 -sDEVICE=pdfwrite input.pdf
I've tried to add: -StrokeWidth=2 but that gave me no effect (I don't even know what kind of measure it wants)
Any ideas/solutions?
Best Regards
Niclas Rådström
it is possible to insert a redefinition of the 'show' operator which strokes the outline of the character with a line width of your choice in addition to the regular show operation. But I agree with Max Wyss that something actually designed to address your problem like a dot gain profile would be a better bet.
/show{gsave dup true charpath .025 setlinewidth stroke grestore //show}def

ANSI escape codes in GNU Smalltalk

I'm trying to make a console-based program that makes use of ANSI escape codes with GNU Smalltalk. I can't seem to figure out how to go about printing a string object formatted with ANSI escape codes. I've tried the following.
'\x1b[31mHi' displayNl
This prints the entire string, including the escape code, without any formatting. I would have expected this to print "Hi" in red (and then everything else in the console after that, as I didn't reset the color.)
After googling a bit, I was able to find a couple issues on mailing lists where people were trying to produce things like newlines using "\n". Most of the answers were using the Transcript object's cr method, but I didn't find anything about colors in the textCollector class.
It looks like it shouldn't be all that hard to create my own module in C to achieve this functionality, but I'd like to know if there's a better way first.
I'm aware of the ncurses bindings, but I'm not sure that'd be practical for just making certain pieces of text in the program colored. So, is there a standard way of outputting colored text to the terminal in GNU Smalltalk using ANSI escape sequences?
Ended up getting an answer on the GNU Smalltalk mailing list. Looks like you can use an interpolation operator to achieve this.
For example ('%1[31mHi' % #($<16r1B>)) displayNl. would change the color to red, and ('%1[34mHi' % #($<16r1B>)) displayNl. would change the color to blue.
Basically, the % operator looks for a sequences that look like "%(number)" and replaces them with the objects in the array to the right of the operator. In our case, the array has one item, which is the ascii escape character in hexadecimal. So the "%1" in "%1[31mHi' is being replaced with the escape character, and then printed.
(This answer was stolen almost verbatim from Paolo on the GNU Smalltalk mailing list.)

Making the PDF format readable and diff-able

I am wondering if anyone have thought of a way to display the PDF document format in a more human readable form?
Now, to compare PDF files, or see exactly what have changed between to versions is very difficult. Many changes aren't visible to the naked eye since they are not a part of the graphical representation(as "created when", and similar).
So if a PDF is a result of an integration test, it is difficult to find the problem without a hex-editor. Also, it is difficult to disregard "created when" in the comparison.
I am not talking any interpretation and displaying, just converting the basic object types to some meta-language. For simplicity's sake, let's say XML. And name nodes like they are named in the PDF specification.
There are PDF-parsers available for most programming languages. Still, at least I, can't find anyone that have gone the distance to convert it to something readable.
Or have I missed it?
Edit:
To clarify(example from specification):
BI % Begin inline image object
/W 17 % Width in samples
/H 17 % Height in samples
/CS /RGB % Color space
/BPC 8 % Bits per component
/F [ /A85 /LZW ] % Filters
Would become:
<BI>
<W>17</W>
<H>17</H>
<CS><RGB/></CS>
<BPC>8</BPC>
<F>
<item>A85</item>
<item>LZW</item>
</F>
</BI>
..and so on.
Binary data could either be extracted to a file or just show a hash or size.

Limiting a match in vim to certain filetypes?

I have the following in my .vimrc to highlight lines longer than 80 chars:
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.*/
This works quite well. However, the problem is that I would prefer it if it only worked on certain file types. Basically, any programming language should be highlighted and things like html, xml, and txt files should not be. I'm pretty sure I could do this easily with an autocmd, but I'm not sure if that is the best way to accomplish that goal. Anybody have any opinions?
Sounds like you might want something like:
autocmd FileType html,xml highlight OverLength ctermbg=red ctermfg=white guibg=#592929
autocmd FileType html,xml match OverLength /\%81v.*/
Seems to work for me anyway :-)
The issue with using match for a task like this is that it is local to the active window, not to the buffer being edited. I'd try something along the following lines:
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
fun! UpdateMatch()
if &ft !~ '^\%(html\|xml\)$'
match OverLength /\%81v.*/
else
match NONE
endif
endfun
autocmd BufEnter,BufWinEnter * call UpdateMatch()
Basically, you want to trigger whenever the buffer in the current window changes. At that point, you evaluate what filetype the buffer has and adjust whether the match should be active or not.
If you also want to support editing an unnamed buffer and then setting its filetype (either via saving or manually setting &ft), the FileType even should be added to the list.