I'm trying to plot colored histogram in subfigure environment. But when setting chart dimensions to \linewidth I got what follows, which is definitely not what I expect.

enter image description here

        \addplot coordinates {(0,117)};
        \addplot coordinates {(1,1041)};
        \addplot coordinates {(10,2162)};
        \addplot coordinates {(11,776)};
    \caption{Histogram of $I_{sc}$}

How can I force pgfplots to occupy all the given space/remove padding/margins/or whatever it is?

If scale only axis used as suggested, margin is still present and chart lands into next subplot.

enter image description here

Partial solution is to set ytick=\empty solves placement problem, but removes ticks entirely...

  • 1
    When you set width=X, height=Y, the dimensions of the axis box itself becomes (X-45pt) by (Y-45pt), where 45pt is a hardcoded length pgfplots adds to give space for labels. If you add scale only axis, the dimensions of become X by Y. If adding scale only axis isn't enough, you could try tex.stackexchange.com/questions/561201/… though. Nov 10 '20 at 20:46
  • Is there a way to drop those margins? Scale only axis will result in overflow
    – majkrzak
    Nov 10 '20 at 21:31
  • Which margins exactly? Sorry though, I don't have any really good options. A perhaps pragmatic, albeit manual, option is to do e.g. scale only axis, width=0.98\linewidth,... Nov 10 '20 at 21:43
  • ehrn scale only axes is on, bottom left corner of chart is in same place and right side gets out of subchart part
    – majkrzak
    Nov 10 '20 at 21:45
  • adding \clip (0,0) rectangle (\linewidth, \linewidth); hellped in ugly manner
    – majkrzak
    Nov 10 '20 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.