A Plots Resolution

Note that, the argument fallbackresolution is used to control the resolution in dpi at which semi-transparent areas are rasterized (the rest stays as vector format). Export to powerpoint You can export the plot to Powerpoint using the ReporteRs package. The pyplot.savefig function provides an optional parameter to control the output resolution, as shown in the following script: Copy import numpy as np from matplotlib import pyplot as plt X = np.linspace(-10, 10, 1024) Y = np.sinc(X) plt.plot(X, Y) plt.savefig('sinc.png', dpi = 300).

At PharmaSUG 2014 in San Diego, I had the pleasure of attending 'Swimmer Plot: Tell a Graphical Story of Your Time to Response Data Using PROC SGPLOT', by Stacey Phillips. In this paper, Stacey presented an interesting graph showing the effects of a study drug on patients' tumor size.

Stacey says in her paper that often 'investigators prefer to dig deeper and look at an individual subject’s pattern of response. A swimmer plot is a graphical way of showing multiple pieces of a subject’s response 'story' in one glance.' The final graph includes a bar showing the length of treatment duration for each patient, classified by the disease stage at baseline, one for each patient in the study. Graph also includes indicators for the start and end of each response episode, classified by complete or partial response, and an indicator showing whether the patient is a 'Durable responder'.

Stacey uses a combination of HBarParm, Scatter and annotations to create this graph. The annotation is used for adding the 'Continued response' arrow, and for the display of the inner legend for decoding of the various symbols in the graph.

Along with many of the attendees of the presentation, I was impressed and intrigued by this visual. I was curious if its creation could be simplified using some of the new features released with SAS 9.3. In particular, I wanted to see if I could make this graph without any annotation.

SAS 9.3 includes some versatile plot statements and features to create graphs. Two of these are the HIGHLOW plot and the Discrete Attributes Map for controlling the color of the group values.

The data used to create the graph is is eyeballed from Stacey's graph and shown above. Updated graph is shown below. Click on the graph for a higher resolution image.

Here are the features of this graph:

  1. This graph uses the High Low plot to draw the bar representing the duration of the response for each subject.
  2. The bar has a arrow on the right side to indicate a continued response. This is explained in the 1st footnote.
  3. Each response episode is represented by start and end events joined by a line classified by the type of response - Complete or Partial. Connecting the start and end event and using a common classification color groups these together as one event, and is easier for the eye to consume. Continuing response does not have an end event on the right.
  4. All event lines and markers are included in the inner legend.

It is also possible to place the indicator for continued event into the key legend using a 'TriangleRightFilled' marker in the graph. This marker is drawn outside the plot region, but is included in the legend. Some items in the legend are shown in grey, to indicate the meaning of the shape since the actual marker will have different colors in the graph based on other criteria.

The graph on the right uses SAS 9.4 with a few aesthetic features for bar skins and filled, outlined markers. Note the shorter line segments in the legend.

Note, the marker for the right arrow in intentionally made bigger to match the right arrows of the HighCap of the HighLow plot.

SAS 9.3 Code:

A plots resolution meaning

The part that I believe makes this version easier to consume is the continuity of the response events. Joining the start and end events with a line segment, all having the same color as per the event classification allows the eye to see each event and its duration clearly.

The part I like best is the graph uses no annotation.

Full SAS 9.3 Code:Swimmer_93

Tags HighCapHighLow PlotSGPLOT procedure

Save Figure with Specific Size, Resolution, or Background Color

Since R2020a. Replaces Save Figure at Specific Size and Resolution (R2019b) and Save Figure Preserving Background Color (R2019b).

Resolution Plot Diagram Definition

Plots

To save plots for including in documents, such as publications or slide presentations, use the exportgraphics function. This function enables you to save plots at the appropriate size, resolution, and background color for your document. The saved content is tightly cropped around the axes with minimal white space. All UI components and adjacent containers such as panels are excluded from the saved content.

Specify Resolution

To save a figure as an image at a specific resolution, call the exportgraphics function, and specify the 'Resolution' name-value pair argument. By default, images are saved at 150 dots per inch (DPI).

For example, create a bar chart and get the current figure. Then save the figure as a 300-DPI PNG file.

Alternatively, you can specify the axes instead of the figure as the first argument to the exportgraphics function.

Resolution

Specify Size

The exportgraphics function captures content at the same width and height as it is displayed on your screen. If you want to change the width and height, then adjust the size of the content displayed in the figure. One way to do this is to create the plot in a tiled chart layout at the desired size without any padding. Then pass the layout to the exportgraphics function.

For example, to save a bar chart as a 3-by-3 inch square image, start by creating a 1-by-1 tiled chart layout t, and set the 'Padding' name-value pair argument to 'none'.

Set the Units property of t to inches. Then set the OuterPosition property of t to [0.25 0.25 3 3]. The first two numbers in the vector position the layout at 0.25 inches from the left and bottom edges of the figure. The last two numbers set the width and height of the layout to 3 inches.

Next, create an axes object by calling the nexttile function. Then create a bar chart in the axes.

Save the layout as a 300-DPI JPEG file by passing t to the exportgraphics function. The resulting image is approximately 3 inches square.

Resolution

An alternative way to change the size is to save the content as a vector graphics file. Then you can resize the content in your document. To save the content as a vector graphics file, call the exportgraphics function and set the 'ContentType' name-value pair argument to 'vector'. For example, create a bar chart, and save the figure as a PDF file containing vector graphics. All embeddable fonts are included in the PDF.

Specify Background Color

By default, the exportgraphics function saves content with a white background. You can specify a different background by setting the BackgroundColor name-value pair argument. These are the possible values:

Plots
  • 'current' — Uses the color of the axes parent container (such as a figure or a panel).

  • 'none' — Sets the background color to transparent or white, depending on the file format and the value of ContentType:

    • Transparent — For files with ContentType='vector'

    • White — For image files, or when ContentType='image'

  • A custom color, specified as an RGB triplet such as [1 0 0], a hexadecimal color code such as #FF0000, or a named color such as 'red'.

For example, create a bar chart, and save the figure as a PDF file with a transparent background.

A Plots Resolution Project

Preserve Axis Limits and Tick Values

A Plots Resolution Definition

Occasionally, the exportgraphics function saves your content with different axis limits or tick values depending on the size of the font and the resolution of the file. To keep the axis limits and tick values from changing, set the tick value mode and limit mode properties on the axes to 'manual'. For example, when plotting into Cartesian axes, set the tick value and limit mode properties for the x-, y-, and z-axis.

For polar plots, set the RTickMode, ThetaTickMode, RLimMode, and ThetaLimMode properties on the polar axes to 'manual'.

See Also

Functions

  • copygraphics exportgraphics nexttile tiledlayout

Properties

  • Axes Properties PolarAxes Properties TiledChartLayout Properties

Resolution Literature

Related Topics