1

I am trying to create a plot representing the number of articles about resilience over a period of time.

The data comes from a txt file, looking like this:

Publication Years   Record Count % of 141519
2025    1   0.001
2024    6705    4.738
2023    19496   13.776
2022    18303   12.933
2021    17338   12.251
2020    13407   9.474
2019    11224   7.931

I only care about the first two numbers. Because it seemed that the spaces were a problem, i edited the file as such:

PublicationYears    RecordCount of141519
2025    1   0.001
2024    6705    4.738
2023    19496   13.776
2022    18303   12.933
2021    17338   12.251
2020    13407   9.474
2019    11224   7.931

My objective is to plot the number of publications over time to show that the word is trendy, and maybe that it's thanks to a publication in particular. No idea why there is a 2025 row, so i ignore it. Deleting it is ok too.

Through googling and asking ChatGpt (that is a very poor tool for this by the way) i manage to end up with this

Plot from code latex code below. A chart of publications over time.

Made from the following code:

\begin{figure}
    \centering
    \begin{tikzpicture}
    \begin{axis}[
        title={Record count by Publication Years for the term "Resilience"},
        bar width=0.5cm,
        width=\textwidth,
        height=8cm,
        ylabel={Record Count},
        xlabel={Publication Years},
        ymin=1,
        xmin=1913,
        xmax=2024,
        enlarge x limits={0.05},
        extra x ticks = {1973},
        extra x tick labels={Publication of Holling's article},
        extra x tick style={grid=major,
            tick label style={yshift=20pt, anchor=east}
            },
        scaled y ticks=false,
        xtick={1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000, 2010, 2020},
        y tick label style={/pgf/number format/.cd,%
            scaled y ticks = true,
            set thousands separator={}},
        x tick label style={/pgf/number format/.cd,%
            scaled x ticks = false,
            set thousands separator={},
            fixed}%
        ]
        \addplot+[smooth, no markers] table [x index=0, y index=1, skip first n=2] {data_sources/wos_resilience_chart.txt};
    \end{axis}
    \end{tikzpicture}
    \caption{Record count by Publication Years for the term "Resilience" present in "Title" or "Abstract" field, when record count is at least 1. Research performed on the Web of Science database on the 15/05/2024.}
    \label{fig:record_count}
\end{figure}

But this is terrible. Tinkering with the plot too much crash my document compiler, and forces me to delete everything and regenerate it all. I am also very unfamiliar with plots, so i lack a lot of lingo to even know what to look for.

I would like to :

  1. Make the Y axis more coherent with the data; it goes from 0 to 20k, so the plot is unreadable until it already reaches a high value

  2. Have the x axis end on the last value, but with the padding like this. I think it's cleaner

  3. Remove the ticks on the top

  4. Have the xmin/xmax and ymin/ymax values added automatically from the txt so that i can update it from the data instead of the code

Is there a way to do all this ?

Thanks

EDIT:

Code than should run on its own. Make sure the columns are separated by tabs and not spaces

\documentclass{article}
\usepackage{pgfplots}
\usepackage{hyperref}

\def\data{

PublicationYears    RecordCount of141519
2025    1   0.001
2024    6705    4.738
2023    19496   13.776
2022    18303   12.933
2021    17338   12.251
2020    13407   9.474
2019    11224   7.931
2018    9413    6.651
2017    7879    5.567
2016    6302    4.453
2015    5221    3.689
2014    4489    3.172
2013    3315    2.342
2012    2957    2.089
2011    2529    1.787
2010    2024    1.430
2009    1777    1.256
2008    1645    1.162
2007    1194    0.844
2006    1062    0.750
2005    839 0.593
2004    679 0.480
2003    565 0.399
2002    503 0.355
2001    387 0.273
2000    376 0.266
1999    290 0.205
1998    286 0.202
1997    224 0.158
1996    181 0.128
1995    136 0.096
1994    117 0.083
1993    126 0.089
1992    110 0.078
1991    67  0.047
1990    18  0.013
1989    25  0.018
1988    18  0.013
1987    41  0.029
1986    24  0.017
1985    28  0.020
1984    19  0.013
1983    10  0.007
1982    19  0.013
1981    7   0.005
1980    17  0.012
1979    16  0.011
1978    18  0.013
1977    14  0.010
1976    11  0.008
1975    2   0.001
1974    3   0.002
1973    4   0.003
1972    2   0.001
1971    4   0.003
1969    9   0.006
1968    3   0.002
1967    1   0.001
1966    3   0.002
1965    3   0.002
1959    1   0.001
1958    2   0.001
1956    1   0.001
1955    1   0.001
1954    1   0.001
1953    1   0.001
1951    1   0.001
1950    2   0.001
1949    4   0.003
1948    2   0.001
1947    2   0.001
1946    3   0.002
1945    1   0.001
1942    1   0.001
1940    1   0.001
1937    1   0.001
1936    1   0.001
1933    1   0.001
1931    1   0.001
1919    1   0.001
1913    4   0.003

}

\begin{document}

\begin{figure}[hbt]
    \centering
    \begin{tikzpicture}
    \begin{axis}[
        title={Record count by Publication Years for the term "Resilience"},
        bar width=0.5cm,
        width=\textwidth,
        height=7cm,
        ylabel={Record Count},
        xlabel={Publication Years},
        ymin=1,
        xmin=1913,
        xmax=2024,
        enlarge x limits={0.05},
        extra x ticks = {1973},
        extra x tick labels={Publication of Holling's article},
        extra x tick style={grid=major,
            tick label style={yshift=20pt, anchor=east}
            },
        scaled y ticks=false,
        xtick={1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000, 2010, 2020},
        y tick label style={/pgf/number format/.cd,%
            scaled y ticks = true,
            set thousands separator={}},
        x tick label style={/pgf/number format/.cd,%
            scaled x ticks = false,
            set thousands separator={},
            fixed}%
        ]
        \addplot+[smooth, no markers] table [x index=0, y index=1, skip first n=2] {data};
    \end{axis}
    \end{tikzpicture}
    \caption{Record count by Publication Years for the term "Resilience" present in "Title" or "Abstract" field, when record count is at least 1. Research performed on the Web of Science database on the 15/05/2024.}
    \label{fig:record_count}
\end{figure}


\end{document}
6
  • 1
    Others know pgf better than I, so I'll leave that to them (unless they don't happen along). But "Tinkering with the plot too much crash my document compiler, and forces me to delete everything and regenerate it all" doesn't sound right to me. What compiler are you using?
    – Teepeemm
    Commented May 16 at 0:05
  • 1
    I think it's latexmk, the one included in the latex vscode extension. Maybe it's something more like it won't regenerate it, but i need to stop all actions, delete aux files, comment the entire figure out, compile and then uncomment it if i make something too wrong with it
    – Orsu
    Commented May 16 at 0:09
  • 2
    Welcome! Is your document being recompiled automatically when you change the code? I know that is popular, but I would turn it off in this kind of case, even if you like it generally. There are cases where you do need to delete generated files - there's no avoiding the truth of that - but it shouldn't be routine. Are you working on the picture in a larger document? If so, put it in a file of its own so there's nothing much to recompile. And please provide code we can compile, ensuring you include any compat setting for pgfplots.
    – cfr
    Commented May 16 at 4:09
  • 2
    Welcome. // I recognize a number of problems with and related to your question. Unordered: (1) your code won't compile; please add what's missing. (2) your data don't represent the curve you show. (3) I don't understand your issue #1 and #4. (4) you raise more than one question, breaking this sites pattern (1 Q == 1 problem, each A == one solution); please cut down. (5) semilog or loglog would be a means to deal with huge ranges. (6) not sure what your visual message shall be. (7) smoothing tends to be cheating. // Hm, please rework your Q. Thank you
    – MS-SPO
    Commented May 16 at 5:30
  • 1
    @MS-SPO Hi, i've added code that should allow it to be run alone. In my question, i only showed a portion of the data as to not drown the page in rows. I'll try semilog, thank you. The message is meant to show that this paper started a trend (kind of). I'm not proving a thing, the plot is more illustrative than anything else. I need to delete some rows anyway, it's impossible that there has been papers on the subject published in 2025. Thank you
    – Orsu
    Commented May 16 at 7:36

1 Answer 1

3

Here is one way to do it. Some remarks:

  • I basically kept your code, removing some options
  • both to gain insight and to make your plot more telling, I used semilog
  • besides your way to put a label via extra tick I put some demo-text using axis cs: (the coordinate system of the axis)

Contentwise, the article you mention didn't change the exponential development in any way ...

result

\documentclass{article}
\usepackage{pgfplots}
%\usepackage{hyperref}

\begin{document}

\begin{figure}[hbt]
    \centering
    \begin{tikzpicture}
    \begin{semilogyaxis}[           % <<<
        title={Record count by Publication Years for the term ``Resilience''}, % !!
        bar width=0.5cm,
        width=\textwidth,
        height=7cm,
        ylabel={Record Count},
        xlabel={Publication Years},
%        ymin=1,            % now it scales automatically
%        xmin=1913,
%        xmax=2024,
        %xmax=2040,         % use this, if you want a larger range to be displayed
        enlarge x limits={0.05},
        extra x ticks = {1973},
        extra x tick labels={Publication of Holling's article},
        extra x tick style={grid=major,
%            tick label style={yshift=20pt, anchor=east}
            tick label style={yshift=2cm, anchor=east}  % <<<
            },
        scaled y ticks=false,
        % less dense x-scale
%        xtick={1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000, 2010, 2020},
        y tick label style={/pgf/number format/.cd,%
            scaled y ticks = true,
            set thousands separator={}},
        x tick label style={/pgf/number format/.cd,%
            scaled x ticks = false,
            set thousands separator={},
            fixed}%
        ]
%        \addplot+[smooth, no markers] table [x index=0, y index=1, skip first n=2] {data.txt};
        \addplot[, no markers] 
            table [x index=0, y index=1, skip first n=2] 
            {data.txt};
            
        % ~~~ putting text in axis coordinates ~~~~~~~~
        \node[anchor=west,teal] at (axis cs:1973,3000) {Some demo text};    
    \end{semilogyaxis}
    
    \end{tikzpicture}
    \caption{Record count by Publication Years for the term "Resilience" present in "Title" or "Abstract" field, when record count is at least 1. Research performed on the Web of Science database on the 15/05/2024.}
    \label{fig:record_count}
\end{figure}

\end{document}

With data.txt as you posted:

PublicationYears    RecordCount of141519
2025    1   0.001
2024    6705    4.738
2023    19496   13.776
2022    18303   12.933
2021    17338   12.251
2020    13407   9.474
2019    11224   7.931
2018    9413    6.651
2017    7879    5.567
2016    6302    4.453
2015    5221    3.689
2014    4489    3.172
2013    3315    2.342
2012    2957    2.089
2011    2529    1.787
2010    2024    1.430
2009    1777    1.256
2008    1645    1.162
2007    1194    0.844
2006    1062    0.750
2005    839 0.593
2004    679 0.480
2003    565 0.399
2002    503 0.355
2001    387 0.273
2000    376 0.266
1999    290 0.205
1998    286 0.202
1997    224 0.158
1996    181 0.128
1995    136 0.096
1994    117 0.083
1993    126 0.089
1992    110 0.078
1991    67  0.047
1990    18  0.013
1989    25  0.018
1988    18  0.013
1987    41  0.029
1986    24  0.017
1985    28  0.020
1984    19  0.013
1983    10  0.007
1982    19  0.013
1981    7   0.005
1980    17  0.012
1979    16  0.011
1978    18  0.013
1977    14  0.010
1976    11  0.008
1975    2   0.001
1974    3   0.002
1973    4   0.003
1972    2   0.001
1971    4   0.003
1969    9   0.006
1968    3   0.002
1967    1   0.001
1966    3   0.002
1965    3   0.002
1959    1   0.001
1958    2   0.001
1956    1   0.001
1955    1   0.001
1954    1   0.001
1953    1   0.001
1951    1   0.001
1950    2   0.001
1949    4   0.003
1948    2   0.001
1947    2   0.001
1946    3   0.002
1945    1   0.001
1942    1   0.001
1940    1   0.001
1937    1   0.001
1936    1   0.001
1933    1   0.001
1931    1   0.001
1919    1   0.001
1913    4   0.003
3
  • 1
    Oh yeah it's exactly what it should (i guess) look like. Maybe i'll remove the emphasis on the article, since it's not as drastic as i'd hope, but it's really quoted as being the one that started the whole movement. Thank you very much!
    – Orsu
    Commented Jun 3 at 15:42
  • 1
    Thank you. // Once again, we have no real perception of exponential growth, though our eyes, ears etc. use it all the time. So the onset (patient 0 so to say) would be more around 1960. Even, if this document from Hollings is important in some respect, it had precursors. That’s at least what this development suggests and which can be verified or falsified.
    – MS-SPO
    Commented Jun 3 at 16:21
  • 1
    Oh yeah definitely, i don't think he'd use the term out of the blue. Some psychology paper from the 50s already used it out the traditional physical meaning. But once again, he's often quoted as being the precursor to it; i meant to indicate that the term is becoming hugely popular more than indicating it's all thanks to holling, or someone else
    – Orsu
    Commented Jun 3 at 18:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .