Show a line chart with only one series

日本語のページ

This page explains how to display a simple line chart with only one series.

Results of running a program to display a line chart

1. Create the source data for the chart

Enter the data that will be the source of the chart in an Excel sheet.
Enter the values ​​for the X-axis and Y-axis as shown in the image below.

Example of source data for line chart

2. Add blocks

Following the steps on the "Creating and displaying charts" page, add the minimum required blocks.
Then, between the chart initialization and chart display blocks, add a block to display the line chart.

Draw a line chart

This block is long horizontally, so it may be difficult to use if the width of the screen is narrow.
In that case, right-click the block and click "External Input" in the menu to change it to a vertical shape.
You can also right-click a vertical block and click "Inline Input" in the menu to change it to a horizontal shape.

3. Setting the source data for the chart

Use the cell range specification block in the "Excel" - "Cells" group to specify the cell range containing the data that will be the source of the chart with the "X" and "Y" parameters.

Block for specifying cell range

If you have entered the item name in the first row of the data, you can also enter the item name in the cell range with the "Y" parameter.

4. Formatting

You can set the format of the line chart using parameters such as "Line width" and "Line type" in the line chart creation block.
The "Label" parameter specifies the label to be added to the line chart series.
If you also include the item name in the cell range in the "Y" parameter, drag the "first value of Y" block in the "matplotlib" - "General chart" group to the "Label" parameter.

First Y value

5. Example

Let's assume that you are entering data into Excel, as in the previous example.

Example of source data for line chart

In this case, specify cells A2 to A6 for the "X" parameter.

Also, specify cells B1 to B6, including the first item name, for the "Y" parameter.

In addition, drag the "First Y value" block to the "Label" parameter.

Example of drawing a line chart with one series

When you run this program, the chart at the top of this page will be displayed.

The file for this example can be downloaded from here.
Also, the Excel data file used in this example can be downloaded from here.
When running this example, make sure you have the data file open in Excel beforehand.