4
$\begingroup$

I'm looking for a way to make a plot similar to the one I've sketched. plot with axis break

So far all I've found is this discussion, which mostly uses Grid. I want the second part of the plot to have a smaller interval, as shown, but when I try their technique, I get this plot:

Grid@{{Plot[Sin[2 x], {x, 0, 4}, PlotRange -> {-1.1, 1.1}, 
  AxesOrigin -> {0, 0}], Style[Rotate["/", 0 Degree], 20], 
  Plot[Cos[2 x], {x, 6, 8}, PlotRange -> {-1.1, 1.1}, Axes -> {True, False}]}}

Mathematica plot with axis break

Notice how the scaling on the second plot changes. I'd like to keep the scaling the same between the first and second plot.

$\endgroup$
1
  • 1
    $\begingroup$ My answer in the linked duplicate candidate may be overkill for your needs, but it is possible to use it to achieve your sketch too. $\endgroup$
    – LLlAMnYP
    Nov 29, 2015 at 13:43

1 Answer 1

4
$\begingroup$
Grid[{{Plot[Sin[2 x], {x, 0, 4}, PlotRange -> {-1.1, 1.1}, 
      AxesOrigin -> {0, 0}, Ticks -> {{1, 2, 3, 4}, Automatic}, AspectRatio -> Full], 
    Style["/", 20],
    Plot[Cos[2 x], {x, 6, 8}, PlotRange -> {-1.1, 1.1}, 
      Axes -> {True, False}, Ticks -> {{6, 7, 8}}, AspectRatio -> Full]}}, 
    ItemSize -> {{10, 1, 5}}]

enter image description here

Note that Ticks is used to provide a common format for the x-axis.

$\endgroup$
1
  • $\begingroup$ thanks, this works for me! I think a key for it is the ItemSize which seems to scale the different parts parts $\endgroup$
    – Hanmyo
    Nov 30, 2015 at 0:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.