A line plot tracks the value of a measurement across a horizontal scale, typically time. It can be used to show trends alone and relative to other individuals or groups in one plot.
Create a Line Plot
- Navigate to the data grid you want to visualize. We will use the Lab Results dataset from the example study for this walkthrough.
- Select (Charts) > Create Chart. Click Line.
- The columns eligible for charting from your current grid view are listed.
- Select the X Axis column by drag and drop, here "Date".
- Select the Y Axis column by drag and drop, here "Lymphs".
- Only the X and Y Axes are required to create a basic line plot. Other options will be explored below.
- Click Apply to see the basic plot.
This basic line chart plots a point for every Lymph value measured for each date, as in a
scatter plot, then draws a line between them. When all values for all participants are mixed, this data isn't necessarily useful. Next, we might want to separate by participant to see if any patterns emerge for individuals.
You may also notice the labels for tickmarks along the X axis overlap the "Date" label. We will fix that
below after making other plot changes.
Line Plot Customizations
Customize your visualization using the
Chart Type and
Chart Layout links in the upper right.
- Chart Type reopens the creation dialog allowing you to:
- Change the X or Y Axis column (hover and click the X to delete the current selection).
- Select a Series column (optional). The series measure is used to split the data into one line per distinct value in the column.
- Note that you can also click another chart type on the left to switch how you visualize the data with the same axes when practical.
- For this walkthrough, drag "Participant ID" to the Series box.
- Click Apply.
![lineMore.PNG](/Documentation/wiki-download.view?entityId=c459ba4e-8ed9-1035-8b1a-fe851e083846&name=lineMore.PNG)
Now the plot draws series' lines between values for the same subject, but is unusably dense. Let's filter to a subset of interest.
- Click View Data to see and filter the underlying data.
- Click the ParticipantID column header and select Filter.
- Click the "All" checkbox in the popup to unselect all values. Then, check the boxes for the first 6 participants, 101-606.
- Click OK.
- Click View Chart to return. Now there are 6 lines showing values for the 6 participants, clearly divided into upward and downward trending values.
![lineLess.PNG](/Documentation/wiki-download.view?entityId=c459ba4e-8ed9-1035-8b1a-fe851e083846&name=lineLess.PNG)
This is a fairly small set of example data, but we can use the line plot tool to check a hypothesis about cohort correlation.
- Click Chart Type to reopen the editor.
- Drag "Study: Cohort" to the Series box. Notice it replaces the prior selection.
- Click Apply.
![lineCohort.PNG](/Documentation/wiki-download.view?entityId=c459ba4e-8ed9-1035-8b1a-fe851e083846&name=lineCohort.PNG)
Now the line plot shows a line series of all points for the participants in each cohort. Remember that this is a filtered subset of (fictional) participants, but in this case it appears there is a correlation. You could check against the broader dataset by returning to view the data and removing the filter.
Add a Second Y Axis
To plot more data, you can add a second Y axis and display it on the right.
- Click Chart Type to reopen the editor.
- Drag the "CD4+" column to the Y Axis box. Notice it becomes a second panel and does not replace the prior selection (Lymphs).
- Click the (circle arrow) to set the Y Axis Side for this measure to be on the right.
- You can see the trend line for each measure for each cohort in a single plot.
Change Chart Layout
The
Chart Layout button offers the ability to change the look and feel of your chart.
![lookFeelLine.png](/Documentation/wiki-download.view?entityId=c459ba4e-8ed9-1035-8b1a-fe851e083846&name=lookFeelLine.png)
There are four tabs:
- General:
- Provide a title to display on the plot. The default is the name of the source data grid.
- Provide a subtitle to display under the title.
- Specify a width and height.
- Control the point size and opacity, as well as choose the default color, if no "Series" column is set.
- Control the line width.
- Hide Data Points: Check this box to display a simple line instead of showing shaped points for each value.
- Number of Charts: Select whether to show a single chart, or a chart per measure, when multiple measures are defined.
- Margins (px): If the default chart margins cause axis labels to overlap, or you want to adjust them for other reasons, you can specify them explicitly in pixels. Specify any one or all of the top, bottom, left, and right margins here.
- X-Axis:
- Label: Change the display label for the X axis (notice this does not change which column provides the data). Click the icon to restore the original label based on the column name.
- Y-Axis:
- Label: Change the display label for the Y axis as for the X axis.
- Scale Type: Choose log or linear scale for the Y axis.
- Range: For the Y-axis, the default is Automatic across charts. Select Automatic Within Chart to have the range based only on this chart. You can also select Manual and specify the min and max values directly.
- Developer: Only available to users that have the "Platform Developers" site role.
- A developer can provide a JavaScript function that will be called when a data point in the chart is clicked.
- Provide Source and click Enable to enable it.
- Click the Help tab for more information on the parameters available to such a function.
- Learn more in this topic.
Adjust Chart Margins
When there are enough values on an axis that the values overlap the label, or if you want to adjust the margins of your chart for any reason, you can use the chart layout settings to set them. In our example, the date display is long and overlaps the label, so before publishing, we can improve the look.
- Observe the example chart where the date displays overlap the label "Date".
- Open the chart for editing, then click Chart Layout.
- Scroll down and set the bottom margin to 140 in this example.
- You can also adjust the other margins as needed.
- Note that plot defaults and the length of labels can both vary, so the specific setting your plot will need may not be 140.
- Click Apply.
- Click Save to save with the revised margin settings.
Save and Export Plots
- When your plot is finished, click Save.
- Name the chart, enter a description (optional), and choose whether to make it viewable by others. You will also see the default thumbnail which has been auto-generated, and can choose whether to use it. As with other charts, you can later attach a custom thumbnail if desired.
Once you have saved a line plot, it will appear in the
Data Browser and on the
(charts) menu for the source dataset. You can manage metadata about it as described in
Manage Data Views.
Export Chart
Hover over the chart to reveal export option buttons in the upper right corner:
![chartExport.PNG](/Documentation/wiki-download.view?entityId=c459ba4e-8ed9-1035-8b1a-fe851e083846&name=chartExport.PNG)
Export your completed chart by clicking an option:
- PDF: generate a PDF file.
- PNG: create a PNG image.
- Script: pop up a window displaying the JavaScript for the chart which you can then copy and paste into a wiki. See Tutorial: Visualizations in JavaScript for a tutorial on this feature.
Related Topics