Hello Michael, I use a similar set up, where I do some systematic computations while changing some parameters or algorithms, and generating csv output files. Then, I generate a set of graphs with veusz in a generic way. Below is a description how I proceed.
As a few files are involved, it would be useful to add something along this direction in the veusz documentation. Gilles ======================================= Set up: - all the veusz scripts are in the directory /home/me/myProject/veusz - the file to plot is in a directory /home/me/myProject/results/parameter_1 - the data to plot is in the file data.csv - the plots are written in the subdirectory /figures of the data directory results/parameter_1. The files 'path_base.txt' and 'path_model.txt' contain the path and sub-path for the data, possibly with some extra parameter for the plot, in the example below the variable logXaxis. --- path_base.txt ---------------------------- # The local base path for this project. basePath = '/home/me/myProject//' ------------------------------- ---- path_model.txt --------------------------- modelSubPath = 'results/parameter_1/' logXaxis = True ------------------------------- The graphs are created with veusz interactively, and saved in the veusz directory. Then, the beginning of the file needs to be edited, so that the correct data file is loaded. Possibly, the variables need to be used in the correct place, in this example to use or not a logarithmic x axis. For example, for the graph_1.vsz file, this gives: --- graph_1.vsz ---------------------------- ImportFileCSV(modelPath + 'data.csv', ...) ... Set('log', logXaxis) ... ------------------------------- where the ImportFileCsv is the first line of the file, before the Add('page', name=u'pageName', autoadd=False) which is unchanged. The Set('log', logXaxis) is in the section for the setting of the horizontal axis. The 'action' is provided by the following file. --- plotAllFigures.vsz ---------------------------- Load('path_base.txt') Load('path_model.txt') outSubPath = 'figures/' scriptPath = basePath + 'veusz/' modelPath = basePath + modelSubPath outPath = modelPath + outSubPath if not os.path.exists(outPath): os.makedirs(outPath) AddImportPath(modelPath) figures = ['graph_1', 'graph_2', 'graph_3'] for figure in figures: Load(scriptPath + figure + '.vsz'); Export(outPath + figure + '.jpg') Quit() ------------------------------- Generating all the graphs is done in the command line with veusz --listen < plotAllFigures.vsz To use another data directory, or here a logarithmic x-axis, only the file path_model.txt needs to be changed. That's it! (Re-)generating all the graphs for many result directories is done through a shell script. This is convenient for example when some axes have to be identical for all the graphs, but the correct bounds were not know at start. --- plotAllAnalyses ---------------------------- #!/bin/bash echo "modelSubPath = 'results/parameter_1/'" > path_model.txt echo "logXaxis = True" >> path_model.txt veusz --listen < plotAllFigures.vsz echo "modelSubPath = 'results/parameter_2/'" > path_model.txt echo "logXaxis = False" >> path_model.txt veusz --listen < plotAllFigures.vsz ... ------------------------------- ======================================= Some more points. - I am creating one plot per graph.vsz file, mainly for the export, and to have a consistent naming between graph.vsz, graph.jpg or graph.eps files. - when using a version control system (subversion, git, ...), the file path_base.txt should NOT be added, but the same file using another name, say like path_base_generic.txt. Then, everyone should copy/rename/edit with his particular root path. All the root path dependency is in this file. Similarly, the file path_model.txt should NOT be added in the version control system, but say path_model_generic.txt as an example. - One inconvenience of this technique is that the graph.vsz files are modified, and therefore cannot be loaded directly into veusz. But it is simple to replace the "ImportFileCSV(modelPath + 'data.csv', ..." by the full path, or to add before in the file the value for the variable 'modelPath' (and the possible other variables). Then, the file can be executed directly into veusz. But remember, after saving the file with veusz, to edit it again to load the correct data file, and to use the possible variables in the graph. Alternatively, since the vsz files are so nice and logical, most of the modifications can be done directly in the script file. Le lundi, 1 juin 2015, 21:43:28 Michael Clerx a écrit : > Dear all, > > I have a number of veusz plots I'd like to regenerate automatically > every time I update some data. I'm sure I'm missing something obvious in > the docs, but I can't find out how I can use Python to: > > 1. Load an existing Veusz file > 2. Create an EPS plot > 3. And store it somewhere > > Your help would be much appreciated. > > kind regards, > Michael > _______________________________________________ Veusz-discuss mailing list Veusz-discuss@gna.org https://mail.gna.org/listinfo/veusz-discuss