Create a plot with time on x from a csv file

Hello,

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

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

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

Hello,

Have a look to timeseries and stackedplot.

S.

Thanks,

Start like this but problem with “VariableNames”

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"])

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

--> 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      

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

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