# Create a plot with time on x from a csv file

**URL:** <https://scilab.discourse.group/t/create-a-plot-with-time-on-x-from-a-csv-file/1122>\
**Category:** Data handling\
**Created:** [February 15, 2026, 12:35pm UTC](https://scilab.discourse.group/t/create-a-plot-with-time-on-x-from-a-csv-file/1122 "2026-02-15T12:35:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![David1](https://avatars.discourse-cdn.com/v4/letter/d/73ab20/32.png) [@David1](https://scilab.discourse.group/u/David1)\
**Post date:** [February 15, 2026, 12:35pm UTC](https://scilab.discourse.group/t/create-a-plot-with-time-on-x-from-a-csv-file/1122/1 "2026-02-15T12:35:27Z")

</div>

Hello,

I’ve a csv file wich contain a log with a timestamp like this

```auto
Timestamp;CPU_Usage_Percent;Memory_MB;Disk_Read_KBps;Disk_Write_KBps
2026-02-15 12:18:29;0,00;32;0,00;0,00
2026-02-15 12:18:29;0,00;32;0,00;0,00
2026-02-15 12:18:29;0,00;32;0,00;0,00

```

Actually I can read the value and plot them simply like this

```auto
PathFileName=uigetfile(["*.csv"]);
//Get data from csv-file with European formating (, separator) and , as decimal
data = csvRead(PathFileName,';',',');
//Remove first line
data = data(2:$,:);
//Remove empty lines
data_values = data(data(:,1) <> "", :);

NbLine = size(data_values);
timestamps_str = data(:,1);
CPU = data(:,2);
Memory = data(:,3);
ReadKb = data(:,4);
WriteKb = data(:,5);

f = scf();
plot(CPU,'b');
title("CPU")

```

Now I would like to add the Timestamp from my csv to make the x axis.

I don’t understand in the plot function how to do this.

Thanks for your help

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [February 15, 2026, 8:20pm UTC](https://scilab.discourse.group/t/create-a-plot-with-time-on-x-from-a-csv-file/1122/2 "2026-02-15T20:20:26Z")

</div>

Hello,

Have a look to timeseries and stackedplot.

S.

---

<div class="post-metadata">

**Author:** ![David1](https://avatars.discourse-cdn.com/v4/letter/d/73ab20/32.png) [@David1](https://scilab.discourse.group/u/David1)\
**Post date:** [February 15, 2026, 9:12pm UTC](https://scilab.discourse.group/t/create-a-plot-with-time-on-x-from-a-csv-file/1122/3 "2026-02-15T21:12:16Z")

</div>

Thanks,

Start like this but problem with “VariableNames”

```auto
clc();clear();

PathFileName=uigetfile(["*.csv"]);
ts = readtimeseries(PathFileName, "VariableNames", ["DateTime", "CPU", "Memory", "ReadKb", "WriteKb"])

CPU = ts(ts.location == "CPU")
Memory = ts(ts.location == "Memory") 
ReadKb = ts(ts.location == "ReadKb")
WriteKb = ts(ts.location == "WriteKb")

stackedplot(CPU, Memory, ReadKb, WriteKb, "LegendLabels", ["CPU", "Memory", "ReadKb", "WriteKb"])

```

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [February 16, 2026, 9:22am UTC](https://scilab.discourse.group/t/create-a-plot-with-time-on-x-from-a-csv-file/1122/4 "2026-02-16T09:22:09Z")

</div>

Just let readtimeseries figure out what the variable names are (first line of the csv file) :

```scilab
--> ts = readtimeseries("data.csv")

 ts = [3x4 timeseries]

        Timestamp CPU_Usage_Percent Memory_MB Disk_Read_KBps Disk_Write_KBps
   ____________________________________  _______________________  _______________
                                                                                         
   2026-02-15 12:18:29 0 32 0 0              
   2026-02-15 12:18:29 0 32 0 0              
   2026-02-15 12:18:29 0 32 0 0      

```

---

<div class="post-metadata">

**Author:** ![David1](https://avatars.discourse-cdn.com/v4/letter/d/73ab20/32.png) [@David1](https://scilab.discourse.group/u/David1)\
**Post date:** [February 16, 2026, 9:58pm UTC](https://scilab.discourse.group/t/create-a-plot-with-time-on-x-from-a-csv-file/1122/5 "2026-02-16T21:58:24Z")

</div>

Great it works but on the x axis there is no label

```auto
PathFileName=uigetfile(["*.csv"]);
ts = readtimeseries(PathFileName)
stackedplot(ts)

On the screen below you can see that the value are loaded successfully. But the timestamp don't appears on the x axis. Is there a solution to set the grid , every second or minute for example.

Thanks

```

 ![1](https://global.discourse-cdn.com/free1/uploads/utc/original/2X/a/a02ce586461268033a2ea3c753fea5e65c6d50a7.png)
