pyahmed / PyCORN

A script to extract data from ÄKTA/UNICORN result-files (.res)
46 stars 25 forks source link

Enhancement: possibility to plot several data blocks on same graph #5

Closed Guillawme closed 9 years ago

Guillawme commented 9 years ago

Hi,

It would be useful to have a way to plot several data blocks chosen by the user on the same graph. Typical use cases I have in mind:

I'm sure there are other use cases but those are the most typical I can think of.

pyahmed commented 9 years ago

Yes I agree, this has been requested before :-)

At the moment I'm not sure how to implement it (still learning python). I would either make it user-configurable or make some presets - whichever is more easy to implements and covers most of the use-cases.

wackywendell commented 9 years ago

My suggestion for making this work is not to try and add it to the CLI interface - there's too many possibilities to try and cover there - but instead to make pycorn easily integratable into someone else's scripts so they can have it do exactly what they want, including things we could not possibly foresee. For example: what if they want the lines to be different colors? Or the same color? One to be dashed? Do we add a legend? These are all easy things to do from within Python, but writing a CLI for every matplotlib feature seems a bit overkill.

If we do it the modular way, the first step, I think, is #6. From there, I suggest splitting up the plotter() function into a few functions:

Then, to plot multiple graphs on the same plot, we can either slightly change the plotter() function to be Pycorn.plotter(self, *datasets, ax=None) (in which case one can specify one or more datasets, and it would put them on the same graph), or just have people call plot_fractions and plot_line themselves.

Also, a couple things to note:

Then a nice thing to do would be to write a couple example scripts, and make an IPython notebook or two, to make it clear how to do these things. How does that sound?

Guillawme commented 9 years ago

Hi,

From a user's point of view (reminder: I'm not able to write any real code), this sounds like an interesting approach. Provided the tool is still usable for a non-programmer (by calling the script from the command line with options and arguments), with the added feature of being able to plot multiple datasets (possibly even from different files as you suggest, which could be super useful to plot multiple gel filtration chromatograms from different runs to compare them) on the same graph, I think that all enhancements you propose can only make the tool more attractive to other programmers. I quickly went through #6 as well and only vaguely understood the technical details, but this sounds promising to me. :smiley:

pyahmed commented 9 years ago

@wackywendell I see where you're going with this and I agree with splitting and making it more modular.

As a 'regular' user of the script I mostly need to do the same thing most of the times. Therefor I personally would like a --preset option (for the CLI-part) that covers most of the common cases. Anything more fancy would require more effort from the user.

If your current approach makes this (--preset) eventually even easier - then go go go! :wink:

pyahmed commented 9 years ago

Multiple data-blocks (from same run) now works in the dev-branch more or less automagically for UV1/2/3. If any of the three wavelenghts is not set (=0nm) it is skipped automatically. With --par1 and --par2 you can show Conductivity and Concentration (--par1 Cond --par2 Conc).

More stuff coming :-)

Guillawme commented 9 years ago

Thank you so much. :+1: Unfortunately I finished making figures for my PhD thesis just a few weeks ago... The workaround I used was to plot as SVG files and simply use Inkscape to copy the second curve and paste it over the first one (way easier than using CSV data to draw a figure from scratch). But sure I will use your new option next time I need this kind of plots!

pyahmed commented 9 years ago

PyCORN is now on PyPI and by default plots more data blocks on a single plot. Installation: pip install pycorn After that pycorn-bin.py should be available and in PATH (tested on Windows&Linux).