2

Below is my code:

\documentclass[11pt,oneside,openany]{book}
\usepackage[a4paper, left=1.5cm, right=1.5cm, top=3cm, bottom=3cm]{geometry}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning}
\tikzset{bullet/.style={circle,fill,inner sep=2pt}}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            ymin=0, ymax=10,
            minor y tick num = 3,
            area style,
            ]
            \addplot+[ybar interval,mark=no] plot coordinates { (0, 9.52) (18 868.3692, 9.72) (45 000, 0) };
        \end{axis}
    \end{tikzpicture}
\end{document}

I wish my diagram to be like the one below (handwritten)enter image description here

Current result:

Current result

SebGlav
  • 19,186
itc
  • 657
  • No, it doesn't. – itc Aug 10 '21 at 17:50
  • Your system of units on the y axis is not correctly set. On your handwritten graph, every space between horizontal lines equals 0.2, so that the point of origin is at 8.92, not 0. You have to set your ymin at 8.92 (and change some other parameters if you want to reflect what you drew). – SebGlav Aug 10 '21 at 18:21
  • "No, it doesn't" is not helpful at all. Are you looking for a font that looks handwritten? https://tex.stackexchange.com/questions/48002/hand-written-fonts-in-latex-xetex-luatex – hpekristiansen Aug 10 '21 at 20:03
  • Im very sorry for the understanding. I wasnt looking for something that looks handwritten. My aim was to produce the output as in that image i posted. @Zarko managed to help with what I was looking exactly. – itc Aug 10 '21 at 21:24
  • @hpekristiansen I think we can delete all these comments about the misunderstanding now. – Alan Munn Aug 12 '21 at 22:19

1 Answers1

5

Like this?

enter image description here

\documentclass[border=3.141592]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=left, xmax=45 000, ymin=7, ymax=10,
restrict y to domain=7:10, ytick=\empty, extra y ticks={8, 9, 9.52, 9.72, 10}, extra y tick style={tick label style={font=\scriptsize}}, ylabel={Weighted Cost of Capital %}, axis y discontinuity=crunch, xtick=\empty, extra x ticks={0, 18 868.3692, 45 000}, xlabel={Total financing}, enlargelimits=0.1, area style, ]

\addplot +[ybar interval] coordinates { (0, 9.52) (18 868.3692, 9.72) (45 000, 9.72) };

\end{axis} \end{tikzpicture} \end{document}

Zarko
  • 296,517
  • It finally worked. I have been struggling to come with this output. – itc Aug 10 '21 at 20:50
  • +1: Hi Zarko. But why the y-axis not is a straight line? – Sebastiano Aug 10 '21 at 22:53
  • @Sebastiano, I use it for purpose: axis y discontinuity=crunch should indicate that in diagram is part between y=0 and y=7 is skipped. By this is "magnified" values between y=9 and y=10. Maybe axis y discontinuity=parallel be more indicative. – Zarko Aug 11 '21 at 05:32