X axis ordered by date?

Hello! I’m testing MultiQC for proteomics data and I’m wondering if there’s a way to order the X axis by date (for instance, dd/MM/YY hh:mm) from older to newer. So what we want is to see how the QC parameters changes across time (a classical time series).

Hi @rolivella!

Could you give a little more context please? X axis of what? A screengrab or something would help.



Hi @ewels !

Yes, I’m would like to ask if we can do plots like this:

The X axis is time, for instance “2024-03-23 11:40:36” for a particular data point. The Y axis is a measure if the area of some QC peptides (EYE, YIC, etc.). We have similar QC plots for other parameters but always with the same time X axis.

Is it more clear now?



Understood, thanks :+1: I don’t think that there are any existing plots that have a datetime axis like this, so I think it’s unlikely that it’s supported at present. Best bet is to put in a GitHub issue requesting it. The underlying plotting library definitely supports it, so hopefully it shouldn’t be a big task.

Short term, two workarounds spring to mind - if all the points are shared and the data points are evenly distributed, you could treat the x axis as categorical data and it should sort of work. Alternatively, you could convert the dates / times into a unix timestamp so that they behave as a simple integer and can be treated as a numerical axis. But then the labels will be nonsensical. So neither approach is perfect.

Tagging @vlad.savelyev for visbility.


OK, thank you very much! It’s not urgent so I can put it in a GitHub issue requesting it.


1 Like

Values like “2024-03-23 11:40:36” should work well as X-axis values, and get the right sorting. Plotly will even recognize it as a timestamp and render nicely:

lineplot_data = {
    "sample1": {
        str(datetime.datetime.today()): 1,
        str(datetime.datetime.today() + datetime.timedelta(days=1)): 2,
        str(datetime.datetime.today() + datetime.timedelta(days=2)): 3,
        str(datetime.datetime.today() + datetime.timedelta(days=3)): 5,
        str(datetime.datetime.today() + datetime.timedelta(days=4)): 2,
        str(datetime.datetime.today() + datetime.timedelta(days=5)): 3,
        str(datetime.datetime.today() + datetime.timedelta(days=6)): 4,
        str(datetime.datetime.today() + datetime.timedelta(days=7)): 5,

    name="Line Plot",
    description="Line plot test.",
    plot=linegraph.plot(lineplot_data, pconfig={"id": "test_line_plot"}),

And the X axis orderred automatically as well by date.

lineplot_data = {
    "sample1": {
        str(datetime.datetime(2024, 3, 10)): 2,
        str(datetime.datetime(2024, 3, 7)): 10,
        str(datetime.datetime(2024, 3, 5, 1, 30)): 1,
        str(datetime.datetime(2024, 3, 6, 18, 10)): 4,
        str(datetime.datetime(2024, 3, 8, 12, 2)): 2,

So not sure if there is an issue here. Let me know if that’s not working for you or if I misunderstood the question, @rolivella.

Thanks @vlad.savelyev ! Looks promising. As I’m working with non-standard multiqc data (proteomics data) I’m using a customized JSON like this test:

  "id": "custom_data_lineplot_2",
  "section_name": "Mass accuracy",
  "description": "This is the mass accuracy.",
  "plot_type": "linegraph",
  "pconfig": {
    "id": "custom_data_linegraph2",
    "title": "Mass accuracy",
    "ylab": "Mass accuracy (ppm)",
    "xDecimals": false,
    "ymax": "2",
    "ymin": "-2"

  "data": {
    "LVN": { "24/03/2024": -0.20262053803095767,"25/03/2024": -0.50262053803095767},
    "HLV": { "24/03/2024": -0.30262053803095767,"25/03/2024": -0.10262053803095767}

How should I apply those Plotly timestamps to this JSON? Thanks!

Your JSON works for me:

multiqc test_mqc.json

What are you getting? How are you running MultiQC?

Yes yes, is working, I meant now I’m using this string “24/03/2024”. Should I put it in another format in order Plotly to get it as timestamp? Now is a “string”, I’m wondering if I have put it as a “timestamp”, do you know what I mean?

Going on @vlad.savelyev’s suggestion above:

Python 3.12.1 | packaged by conda-forge | (main, Dec 23 2023, 08:01:35) [Clang 16.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> str(datetime.datetime.today())
'2024-03-28 13:22:17.508050'

So 24/03/20242024-03-24 00:00:00.000000

I suspect that Plotly will be relatively forgiving and that you can cut some / all of the timestamp off the end. But maybe start with this and see if it works first.


1 Like

Right on, in order for Plotly to recognize a string as a date, it needs to be in ISO format:

  "data": {
    "LVN": { "2024-03-24": -0.20262053803095767,"2024-03-25": -0.50262053803095767},
    "HLV": { "2024-03-24": -0.30262053803095767,"2024-03-25": -0.10262053803095767}

Your original “24/03/2024” format sort of works as Plotly interprets it as a plain string category, but since it would sort it alphanumerically - date first - month second - this is not ideal. So if you change the format to “2024-03-24”, it should work as expected.

Yes, the format did the trick. By putting dates in this format “2024-03-24 11:00” the X axis worked as expected.

Thank you both for the help!

1 Like

Great! Thanks for letting us know!