Author Topic: More modifications to an exported plot  (Read 7354 times)

Ron D.

  • Administrator
  • Newbie
  • *****
  • Posts: 39
    • View Profile
More modifications to an exported plot
« on: May 27, 2015, 12:47:16 AM »
The forum topic titled Accentuating individual lines in an exported plot describes how to directly edit the PostScript file that is created in the process of generating an exported PDF file in order to change the color, opacity and linewidth of individual lines. However, there are other characteristics of the PDF output that you might wish to edit as well. Some of these other characteristics can be changed in Sliver before you export the plot to PDF, but sometimes you don't want to reload a session file just to change one or two attributes of the exported plot.

For example, have a look at the following PDF file (which is rendered better by downloading it and opening it in Acrobat rather than in your browser). It is a PC plot of the split paces (minutes per mile for each 5K split and the finish split) for the top 5000 finishers of the 2015 Boston Marathon.

http://www.sliversoftware.com/Download/Team_Split_Paces_Among_Top_5000_Finishers.pdf

In this PDF I altered some of the characteristics of the original PDF file exported from Sliver. The first three changes below were made to the original exported PostScript file, after which a new PDF file was generated from this edited PostScript file using Adobe Acrobat Distiller. Generally you can just double-click on the PostScript file to launch Distiller as the .ps suffix is associated with that program. The fourth change was made directly to the PDF file.

  • The colors, opacity and widths of polylines for several runners were modified and brought to the front.
  • The axis titles were reduced in length so they would not overlap.
  • The original range labels on the axes were in decimal form ("5.0" and "8.0") because the data was in decimal minutes/mile units. The axes were forced to have these ranges by loading the CSV file, saving the session to a session file, editing the last lines of the session file to have these range values, and then reloading the session file, as described in the forum topic Setting custom ranges on axes. However, the altered PDF now displays these values in minutes and seconds ("5:00" and "8:00") because runners think in minutes and seconds.
  • Labels were added at the ends of the modified polylines to identify the names of the associated runners.

The edits made for each of these are described below. You can view the edited PostScript file by opening the following link in a text editor (not the default Adobe Acrobat Distiller):

http://www.sliversoftware.com/Download/Team_Split_Paces_Among_Top_5000_Finishers.ps


1.  Modified Line Parameters

This follows the steps in the Accentuating individual lines in an exported plot forum post. The lines of interest were uniquely colored in Sliver prior to the export (here they were colored white) and this brush was set as the last to draw in order using the Hide and Show options in the Brushes-->Show/Hide/Recolor Brushes menu option. Then the drawing commands for these lines were located in the PostScript file by searching for that color assignment (here "1.0000 1.0000 0.0000 setrgbcolor" where the numbers represent R, G and B values from 0.0 to 1.0). These line commands were then moved to a later section of the PostScript file after the opacity is set to 100% by the two lines

[ /CA 1.0 /BM /Normal /SetTransparency pdfmark
[ /ca 1.0 /BM /Normal /SetTransparency pdfmark

The two lines above already exist later in the file, so the line drawing commands were just moved after these lines. However, if an opacity other than 1.0 is desired, you can create two new command lines that are the same as those above where the "1.0" are replaced with a different opacity between 0.0 and 1.0. Then you can place the line drawing commands after those new lines.

A new linewidth was set by adding the line "0.055 setlinewidth" before the line commands. Finally, because the polylines overlapped in the plot, different colors were assigned to individual lines by inserting text such as "0.0000 0.0000 1.0000 setrgbcolor" for blue in front of each line drawing command.

The final set of commands for these lines is shown below. As mentioned, the SetTransparency lines already existed in the file.

[ /CA 1.0 /BM /Normal /SetTransparency pdfmark
[ /ca 1.0 /BM /Normal /SetTransparency pdfmark

0.065 setlinewidth
1.0000 0.0000 0.0000 setrgbcolor
1.9477 1.8601 m 4.8708 2.0464 l 7.7940 2.0732 l 10.7171 2.3927 l 13.6403 2.5796 l 16.5634 3.1927 l 19.4866 4.4186 l 22.4097 5.5117 l 25.3329 5.9783 l s
1.0000 0.0000 0.0000 setrgbcolor
1.9477 5.8317 m 4.8708 6.4181 l 7.7940 6.0449 l 10.7171 6.3644 l 13.6403 6.3913 l 16.5634 6.9244 l 19.4866 7.2976 l 22.4097 5.7249 l 25.3329 5.4929 l s
0.0000 0.5000 0.0000 setrgbcolor
1.9477 6.6044 m 4.8708 6.7913 l 7.7940 6.7913 l 10.7171 6.8713 l 13.6403 6.6844 l 16.5634 7.2176 l 19.4866 7.1376 l 22.4097 6.4713 l 25.3329 6.3431 l s
1.0000 1.0000 1.0000 setrgbcolor
1.9477 6.7644 m 4.8708 6.8176 l 7.7940 6.7376 l 10.7171 6.8713 l 13.6403 6.7644 l 16.5634 7.5639 l 19.4866 7.2176 l 22.4097 6.7376 l 25.3329 6.0395 l s
1.0000 1.0000 1.0000 setrgbcolor
1.9477 6.7913 m 4.8708 6.7913 l 7.7940 6.7376 l 10.7171 6.8444 l 13.6403 6.7913 l 16.5634 7.5639 l 19.4866 7.4576 l 22.4097 6.8713 l 25.3329 7.4964 l s
1.0000 0.0000 0.0000 setrgbcolor
1.9477 6.2049 m 4.8708 6.7376 l 7.7940 7.1376 l 10.7171 7.0313 l 13.6403 7.1908 l 16.5634 7.4576 l 19.4866 7.4576 l 22.4097 7.1113 l 25.3329 6.8285 l s
0.0000 0.0000 1.0000 setrgbcolor
1.9477 7.2708 m 4.8708 7.5376 l 7.7940 7.5639 l 10.7171 7.3508 l 13.6403 7.2444 l 16.5634 7.8039 l 19.4866 7.8839 l 22.4097 7.1113 l 25.3329 6.5249 l s
1.0000 1.0000 1.0000 setrgbcolor
1.9477 8.0708 m 4.8708 7.5639 l 7.7940 7.4308 l 10.7171 7.6439 l 13.6403 7.3508 l 16.5634 8.2039 l 19.4866 7.8576 l 22.4097 6.9776 l 25.3329 6.3431 l s
0.0000 0.5000 0.0000 setrgbcolor
1.9477 7.3776 m 4.8708 7.4308 l 7.7940 7.5639 l 10.7171 7.3508 l 13.6403 7.2444 l 16.5634 7.8039 l 19.4866 7.8839 l 22.4097 7.2976 l 25.3329 8.9537 l s
0.0000 0.0000 1.0000 setrgbcolor
1.9477 6.7644 m 4.8708 6.7913 l 7.7940 6.7644 l 10.7171 6.9244 l 13.6403 6.7644 l 16.5634 8.2571 l 19.4866 8.8434 l 22.4097 9.6166 l 25.3329 12.2934 l s


2.  New Axis Titles

This was simple. The title of each axis is given in parentheses in lines near the bottom of the file. New text can be inserted in place of the original axis titles. This text is centered, so the new title will remain centered under the axis. This is an example of one of the lines with the new axis title of "5k Pace":

(5k Pace) dup stringwidth pop 2 div neg 0 rmoveto show

Notice that you can change the font, color and size of this text by editing the command lines right above this section.


3.  New Range Labels

This was also simple. The range labels for each axis are given in parentheses in the command lines just below the title line for each axis. New labels can be entered in place of the original labels inside the parentheses. The labels are always right-justified, so they will not overlap the axes. Here the original command lines with values of 5.0 and 8.0 are now replaced with, for example,

(05:00) -2.2230000000000003 1.8167 showRightX
(08:00) 13.2422 1.8167 showRightX

Again, the font, color and size of the text are defined in the command lines located right above this section.


4.  Adding New Text Labels

The runner name labels at the right ends of the polylines were added directly to the PDF file after it was regenerated from the modified PostScript file. There is an option in Adobe Acrobat to Add or Edit Text Box, and there are options to change the font, the font size, the font color and the background color of a text box. So a text box with a black background was created for each runner and placed at the end of that polyline in the plot, where the text color matches the color of their polyline. You can click on those text boxes in the PDF file to see them.


More Tricks:

There are other edits you can make to the PostScript file to customize it. For example, the background color of the plots are given by command lines near the start of the file that draw a filled rectangular background, such as

0.0000 0.0000 0.0000 setrgbcolor
-0.37 -4.07 m 27.57 -4.07 l 27.57  18.07 l -0.37 18.07 l closepath fill stroke

You can edit the first line to change the RGB color of the background. You can also add an overall plot title either by editing the PostScript file or by adding a text box to the PDF in Adobe Acrobat.

You can modify scatterplots in a PostScript file as well. The color, radius and thickness of any particular hollow point can be modified in the PostScript plot in a similar way as we did above for polylines. You can also change the axes labels, colors and thicknesses, as well as add text labels and a title.

-- Ron
« Last Edit: May 27, 2015, 01:27:48 AM by Ron D. »