gnuplot

how to delete a file generated under table mode


I've generated a datafile (ASCII) under table mode,

set table $Temp1
plot string w table
unset table

where string is a previously defined string, which is the name of a data file. This comes actually inside a do-loop; I would like to clear/delete it at every loop after having dealt with it, so as to use it again with other datafiles (whose name will be given by string which will change at every loop). I've searched on the internet if there's such a thing like clear $Temp1, delete $Temp1 or remove $Temp1, but there is no. Would you know how to clear/delete $Temp1 at every loop?


Solution

  • The command set table "filename" creates a file. Notice that the file name is provided in quotes. The command set table $Temp1 does not create a file. It allocates an internal storage area that gnuplot calls a "data block" to hold the output from subsequent plot commands. When you say unset table the program will stop using it for output. Data block names always begin with the $ character.

    It is not usually necessary to explicitly clear or release this internal storage because it will be cleared before reuse if you go through the same procedure again with another set table $Temp1; plot <something>; unset table sequence of commands.

    If you nevertheless want to clear and release this data block explicitly for some reason, you can use the command undefine $Temp1.

    If your intent was really to create a file named $Temp1 rather than direct output to an internal datablock, place the name in quotes. This may or may not be a legal filename depending on your operating system.

    set table "$Temp1"