Cannot overlay, because ListPlot does not draw same X range despite the same PlotRangePlot does not plot over the specified rangeThe same range on each plot in a gridListPlot filling not appearing when point is out of rangeListPlot does not recognize my listListPolarPlot not showing full plot range even with PlotRange -> AllPlot does not take range with OptionValue and PlotRange optionHow to overlay ListPlot on a ContourPlot with correct range?PlotRange -> Automatic/All/Full does not adjust the z-axisArrayPlot does not draw unit diskWhy are these plots not the same?
Compressed gas thruster for an orbital launch vehicle?
What are the consequences for a developed nation to not accept any refugees?
Users forgetting to regenerate PDF before sending it
How to convert diagonal matrix to rectangular matrix
Why AI became applicable only after Nvidia's chips were available?
Are all diatonic chords in the diminished scale diminished?
Would a Nikon FG 20 film SLR camera take pictures without batteries?
Why did Old English lose both thorn and eth?
Adjust the Table
What could cause the sea level to massively decrease?
Why does the Antonov AN-225 not have any winglets?
Is there a strong legal guarantee that the U.S. can give to another country that it won't attack them?
What minifigure is this?
What does collachrimation mean?
What exactly is a "murder hobo"?
How do you move up one folder in Finder?
Distinguish the explanations of Galadriel's test in LotR
Why different specifications for telescopes and binoculars?
Swapping "Good" and "Bad"
Bold and Colored Image Caption
How to properly translate the key phrase of Erdoğan's 2016 letter to Putin, "kusura bakmasınlar," to Russian
What was this character's plan?
Party going through airport security at separate times?
Publishing papers seem natural to many, while I find it really hard to think novel stuff to pursue till publication. How to cope up with this?
Cannot overlay, because ListPlot does not draw same X range despite the same PlotRange
Plot does not plot over the specified rangeThe same range on each plot in a gridListPlot filling not appearing when point is out of rangeListPlot does not recognize my listListPolarPlot not showing full plot range even with PlotRange -> AllPlot does not take range with OptionValue and PlotRange optionHow to overlay ListPlot on a ContourPlot with correct range?PlotRange -> Automatic/All/Full does not adjust the z-axisArrayPlot does not draw unit diskWhy are these plots not the same?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
curveData = Import["D:\Curve.txt", "Table", "FieldSeparators" -> " "]
lineData = Import["D:\Line.txt", "Table", "FieldSeparators" -> " "]
curvePlot = ListPlot[curveData, PlotRange -> 200, 600, All, AxesOrigin -> 200, 0, Frame -> True, True, True, False]
linePlot = ListPlot[lineData, PlotRange -> 200, 600, All, PlotStyle -> PointSize[0], AxesOrigin -> 200, 0, Frame -> False, False, False, True, Filling -> Axis, FillingStyle -> Thickness[Tiny]]
Overlay[curvePlot, linePlot]
I am trying to overlay two plots. However, overlay does not produce aligned plots. The reason seems to be that the plots don't have the same absolute X range, despite the same PlotRange. Could you help to comment the reason ? Many thanks !
Curve.txt
Lines.txt
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
plotting graphics scaling
$endgroup$
add a comment |
$begingroup$
curveData = Import["D:\Curve.txt", "Table", "FieldSeparators" -> " "]
lineData = Import["D:\Line.txt", "Table", "FieldSeparators" -> " "]
curvePlot = ListPlot[curveData, PlotRange -> 200, 600, All, AxesOrigin -> 200, 0, Frame -> True, True, True, False]
linePlot = ListPlot[lineData, PlotRange -> 200, 600, All, PlotStyle -> PointSize[0], AxesOrigin -> 200, 0, Frame -> False, False, False, True, Filling -> Axis, FillingStyle -> Thickness[Tiny]]
Overlay[curvePlot, linePlot]
I am trying to overlay two plots. However, overlay does not produce aligned plots. The reason seems to be that the plots don't have the same absolute X range, despite the same PlotRange. Could you help to comment the reason ? Many thanks !
Curve.txt
Lines.txt
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
plotting graphics scaling
$endgroup$
1
$begingroup$
TryShow
instead ofOverlay
$endgroup$
– Ulrich Neumann
Jun 30 at 11:33
$begingroup$
@UlrichNeumann Could you help to suggest more specifically how to useshow
in this circumstance ? Many thanks !
$endgroup$
– SOUser
Jun 30 at 12:26
add a comment |
$begingroup$
curveData = Import["D:\Curve.txt", "Table", "FieldSeparators" -> " "]
lineData = Import["D:\Line.txt", "Table", "FieldSeparators" -> " "]
curvePlot = ListPlot[curveData, PlotRange -> 200, 600, All, AxesOrigin -> 200, 0, Frame -> True, True, True, False]
linePlot = ListPlot[lineData, PlotRange -> 200, 600, All, PlotStyle -> PointSize[0], AxesOrigin -> 200, 0, Frame -> False, False, False, True, Filling -> Axis, FillingStyle -> Thickness[Tiny]]
Overlay[curvePlot, linePlot]
I am trying to overlay two plots. However, overlay does not produce aligned plots. The reason seems to be that the plots don't have the same absolute X range, despite the same PlotRange. Could you help to comment the reason ? Many thanks !
Curve.txt
Lines.txt
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
plotting graphics scaling
$endgroup$
curveData = Import["D:\Curve.txt", "Table", "FieldSeparators" -> " "]
lineData = Import["D:\Line.txt", "Table", "FieldSeparators" -> " "]
curvePlot = ListPlot[curveData, PlotRange -> 200, 600, All, AxesOrigin -> 200, 0, Frame -> True, True, True, False]
linePlot = ListPlot[lineData, PlotRange -> 200, 600, All, PlotStyle -> PointSize[0], AxesOrigin -> 200, 0, Frame -> False, False, False, True, Filling -> Axis, FillingStyle -> Thickness[Tiny]]
Overlay[curvePlot, linePlot]
I am trying to overlay two plots. However, overlay does not produce aligned plots. The reason seems to be that the plots don't have the same absolute X range, despite the same PlotRange. Could you help to comment the reason ? Many thanks !
Curve.txt
Lines.txt
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
plotting graphics scaling
plotting graphics scaling
edited Jun 30 at 13:15
rhermans
22.4k4 gold badges41 silver badges107 bronze badges
22.4k4 gold badges41 silver badges107 bronze badges
asked Jun 30 at 11:15
SOUserSOUser
1433 bronze badges
1433 bronze badges
1
$begingroup$
TryShow
instead ofOverlay
$endgroup$
– Ulrich Neumann
Jun 30 at 11:33
$begingroup$
@UlrichNeumann Could you help to suggest more specifically how to useshow
in this circumstance ? Many thanks !
$endgroup$
– SOUser
Jun 30 at 12:26
add a comment |
1
$begingroup$
TryShow
instead ofOverlay
$endgroup$
– Ulrich Neumann
Jun 30 at 11:33
$begingroup$
@UlrichNeumann Could you help to suggest more specifically how to useshow
in this circumstance ? Many thanks !
$endgroup$
– SOUser
Jun 30 at 12:26
1
1
$begingroup$
Try
Show
instead of Overlay
$endgroup$
– Ulrich Neumann
Jun 30 at 11:33
$begingroup$
Try
Show
instead of Overlay
$endgroup$
– Ulrich Neumann
Jun 30 at 11:33
$begingroup$
@UlrichNeumann Could you help to suggest more specifically how to use
show
in this circumstance ? Many thanks !$endgroup$
– SOUser
Jun 30 at 12:26
$begingroup$
@UlrichNeumann Could you help to suggest more specifically how to use
show
in this circumstance ? Many thanks !$endgroup$
– SOUser
Jun 30 at 12:26
add a comment |
4 Answers
4
active
oldest
votes
$begingroup$
Here's a way to combine the plots and keep the frame scales that seem intended by the OP. It would have been easier if Charting`ScaledTicks[curveScale, curveScaleInv]
didn't insist that log-spaced major ticks were the way to go. One can use Charting`ScaledTicks
in place of myScaledTicks
in many cases.
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
(* creates scaling functions
* to scale data to canonical 0,1 interval and back *)
ClearAll[scalingFunctions];
scalingFunctions[data_] :=
Function /@ (Rescale[#, #2, #3], Rescale[#, #3, #2] &[#, MinMax@data, 0, 1]);
curveScale, curveScaleInv = scalingFunctions[curveData[[All, 2]]];
lineScale, lineScaleInv = scalingFunctions[lineData[[All, 2]]];
(* creates ticks corresponding to scaling functions *)
ClearAll[myScaledTicks];
myScaledTicks[sf_, isf_][min_, max_, n_: 6, 6] :=
Module[major, minor,
major, minor = FindDivisions[isf@min, max, n] /. x_Rational :> N[x];
minor = Complement[Join @@ minor, major];
major =
sf[#], #,
0.01, 0.,
AbsoluteThickness[0.1]
& /@ major;
minor =
sf[#], Spacer[0, 0],
0.005, 0.,
AbsoluteThickness[0.1]
& /@ minor;
Join[major, minor]
];
Plot of OP's data:
Show[
curvePlot = ListPlot[curveData, PlotRange -> 200, 600, All,
AxesOrigin -> 200, 0, Frame -> True,
ScalingFunctions -> curveScale, curveScaleInv],
linePlot = ListPlot[lineData,
PlotRange -> 200, 600, All, PlotStyle -> PointSize[0],
AxesOrigin -> 200, 0, Filling -> Axis,
FillingStyle -> Thickness[Tiny],
ScalingFunctions -> lineScale, lineScaleInv],
FrameTicks ->
myScaledTicks[curveScale, curveScaleInv],
myScaledTicks[lineScale, lineScaleInv],
Automatic, Automatic,
FrameLabel -> "curve (units?)", "line (units?)", "x (units?)", None
]
$endgroup$
$begingroup$
Thank you for your knowledgeable help !
$endgroup$
– SOUser
Jul 1 at 1:41
$begingroup$
@SOUser You're welcome!
$endgroup$
– Michael E2
Jul 1 at 3:26
add a comment |
$begingroup$
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
curvePlot = ListPlot[
curveData
, PlotRange -> 200, 600, All
, AxesOrigin -> 200, 0
, Frame -> True, True, True, False
];
linePlot = ListPlot[
lineData.DiagonalMatrix[1, 40000]
, PlotRange -> 200, 600, All
, PlotStyle -> PointSize[0]
, AxesOrigin -> 200, 0
, Frame -> False, False, False, True
, Filling -> Axis
, FillingStyle -> Thickness[Tiny]
];
Show[curvePlot, linePlot]
$endgroup$
add a comment |
$begingroup$
Try
Show[curvePlot, linePlot]
As you can see the scaling of your data should be adapted!
$endgroup$
add a comment |
$begingroup$
If you want a more automated version of @MiachelE2's answer, you can use the CombinePlots
function of the ForScience`
paclet (see below for instructions on how to install it) with the setting "AxesSides" -> "TwoY"
(see the documentation of the paclet for more details and examples):
<<ForScience`
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
curvePlot = ListPlot[
curveData,
PlotRange -> 200, 600, All,
AxesOrigin -> 200, 0,
Frame -> True,
FrameLabel -> "x axis", "curve (units?)"
]
linePlot = ListPlot[
lineData,
PlotRange -> 200, 600, All,
PlotStyle -> PointSize[0], Red,
AxesOrigin -> 200, 0,
Filling -> Axis,
FillingStyle -> Thickness[Tiny],
Frame -> True,
FrameLabel -> "x axis", "line (units?)",
FrameStyle -> Red
]
CombinePlots[curvePlot, linePlot, "AxesSides" -> "TwoY"]
Note how the FrameLabel
,FrameTicks
and FrameStyle
of the second plot were automatically moved to the right side
How to install the paclet
The current version (0.88.45) of the paclet can be installed by running
PacletInstall[
"https://github.com/MMA-ForScience/ForScience/releases/download/v0.88.45/ForScience-0.88.45.paclet"
]
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f201265%2fcannot-overlay-because-listplot-does-not-draw-same-x-range-despite-the-same-plo%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Here's a way to combine the plots and keep the frame scales that seem intended by the OP. It would have been easier if Charting`ScaledTicks[curveScale, curveScaleInv]
didn't insist that log-spaced major ticks were the way to go. One can use Charting`ScaledTicks
in place of myScaledTicks
in many cases.
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
(* creates scaling functions
* to scale data to canonical 0,1 interval and back *)
ClearAll[scalingFunctions];
scalingFunctions[data_] :=
Function /@ (Rescale[#, #2, #3], Rescale[#, #3, #2] &[#, MinMax@data, 0, 1]);
curveScale, curveScaleInv = scalingFunctions[curveData[[All, 2]]];
lineScale, lineScaleInv = scalingFunctions[lineData[[All, 2]]];
(* creates ticks corresponding to scaling functions *)
ClearAll[myScaledTicks];
myScaledTicks[sf_, isf_][min_, max_, n_: 6, 6] :=
Module[major, minor,
major, minor = FindDivisions[isf@min, max, n] /. x_Rational :> N[x];
minor = Complement[Join @@ minor, major];
major =
sf[#], #,
0.01, 0.,
AbsoluteThickness[0.1]
& /@ major;
minor =
sf[#], Spacer[0, 0],
0.005, 0.,
AbsoluteThickness[0.1]
& /@ minor;
Join[major, minor]
];
Plot of OP's data:
Show[
curvePlot = ListPlot[curveData, PlotRange -> 200, 600, All,
AxesOrigin -> 200, 0, Frame -> True,
ScalingFunctions -> curveScale, curveScaleInv],
linePlot = ListPlot[lineData,
PlotRange -> 200, 600, All, PlotStyle -> PointSize[0],
AxesOrigin -> 200, 0, Filling -> Axis,
FillingStyle -> Thickness[Tiny],
ScalingFunctions -> lineScale, lineScaleInv],
FrameTicks ->
myScaledTicks[curveScale, curveScaleInv],
myScaledTicks[lineScale, lineScaleInv],
Automatic, Automatic,
FrameLabel -> "curve (units?)", "line (units?)", "x (units?)", None
]
$endgroup$
$begingroup$
Thank you for your knowledgeable help !
$endgroup$
– SOUser
Jul 1 at 1:41
$begingroup$
@SOUser You're welcome!
$endgroup$
– Michael E2
Jul 1 at 3:26
add a comment |
$begingroup$
Here's a way to combine the plots and keep the frame scales that seem intended by the OP. It would have been easier if Charting`ScaledTicks[curveScale, curveScaleInv]
didn't insist that log-spaced major ticks were the way to go. One can use Charting`ScaledTicks
in place of myScaledTicks
in many cases.
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
(* creates scaling functions
* to scale data to canonical 0,1 interval and back *)
ClearAll[scalingFunctions];
scalingFunctions[data_] :=
Function /@ (Rescale[#, #2, #3], Rescale[#, #3, #2] &[#, MinMax@data, 0, 1]);
curveScale, curveScaleInv = scalingFunctions[curveData[[All, 2]]];
lineScale, lineScaleInv = scalingFunctions[lineData[[All, 2]]];
(* creates ticks corresponding to scaling functions *)
ClearAll[myScaledTicks];
myScaledTicks[sf_, isf_][min_, max_, n_: 6, 6] :=
Module[major, minor,
major, minor = FindDivisions[isf@min, max, n] /. x_Rational :> N[x];
minor = Complement[Join @@ minor, major];
major =
sf[#], #,
0.01, 0.,
AbsoluteThickness[0.1]
& /@ major;
minor =
sf[#], Spacer[0, 0],
0.005, 0.,
AbsoluteThickness[0.1]
& /@ minor;
Join[major, minor]
];
Plot of OP's data:
Show[
curvePlot = ListPlot[curveData, PlotRange -> 200, 600, All,
AxesOrigin -> 200, 0, Frame -> True,
ScalingFunctions -> curveScale, curveScaleInv],
linePlot = ListPlot[lineData,
PlotRange -> 200, 600, All, PlotStyle -> PointSize[0],
AxesOrigin -> 200, 0, Filling -> Axis,
FillingStyle -> Thickness[Tiny],
ScalingFunctions -> lineScale, lineScaleInv],
FrameTicks ->
myScaledTicks[curveScale, curveScaleInv],
myScaledTicks[lineScale, lineScaleInv],
Automatic, Automatic,
FrameLabel -> "curve (units?)", "line (units?)", "x (units?)", None
]
$endgroup$
$begingroup$
Thank you for your knowledgeable help !
$endgroup$
– SOUser
Jul 1 at 1:41
$begingroup$
@SOUser You're welcome!
$endgroup$
– Michael E2
Jul 1 at 3:26
add a comment |
$begingroup$
Here's a way to combine the plots and keep the frame scales that seem intended by the OP. It would have been easier if Charting`ScaledTicks[curveScale, curveScaleInv]
didn't insist that log-spaced major ticks were the way to go. One can use Charting`ScaledTicks
in place of myScaledTicks
in many cases.
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
(* creates scaling functions
* to scale data to canonical 0,1 interval and back *)
ClearAll[scalingFunctions];
scalingFunctions[data_] :=
Function /@ (Rescale[#, #2, #3], Rescale[#, #3, #2] &[#, MinMax@data, 0, 1]);
curveScale, curveScaleInv = scalingFunctions[curveData[[All, 2]]];
lineScale, lineScaleInv = scalingFunctions[lineData[[All, 2]]];
(* creates ticks corresponding to scaling functions *)
ClearAll[myScaledTicks];
myScaledTicks[sf_, isf_][min_, max_, n_: 6, 6] :=
Module[major, minor,
major, minor = FindDivisions[isf@min, max, n] /. x_Rational :> N[x];
minor = Complement[Join @@ minor, major];
major =
sf[#], #,
0.01, 0.,
AbsoluteThickness[0.1]
& /@ major;
minor =
sf[#], Spacer[0, 0],
0.005, 0.,
AbsoluteThickness[0.1]
& /@ minor;
Join[major, minor]
];
Plot of OP's data:
Show[
curvePlot = ListPlot[curveData, PlotRange -> 200, 600, All,
AxesOrigin -> 200, 0, Frame -> True,
ScalingFunctions -> curveScale, curveScaleInv],
linePlot = ListPlot[lineData,
PlotRange -> 200, 600, All, PlotStyle -> PointSize[0],
AxesOrigin -> 200, 0, Filling -> Axis,
FillingStyle -> Thickness[Tiny],
ScalingFunctions -> lineScale, lineScaleInv],
FrameTicks ->
myScaledTicks[curveScale, curveScaleInv],
myScaledTicks[lineScale, lineScaleInv],
Automatic, Automatic,
FrameLabel -> "curve (units?)", "line (units?)", "x (units?)", None
]
$endgroup$
Here's a way to combine the plots and keep the frame scales that seem intended by the OP. It would have been easier if Charting`ScaledTicks[curveScale, curveScaleInv]
didn't insist that log-spaced major ticks were the way to go. One can use Charting`ScaledTicks
in place of myScaledTicks
in many cases.
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
(* creates scaling functions
* to scale data to canonical 0,1 interval and back *)
ClearAll[scalingFunctions];
scalingFunctions[data_] :=
Function /@ (Rescale[#, #2, #3], Rescale[#, #3, #2] &[#, MinMax@data, 0, 1]);
curveScale, curveScaleInv = scalingFunctions[curveData[[All, 2]]];
lineScale, lineScaleInv = scalingFunctions[lineData[[All, 2]]];
(* creates ticks corresponding to scaling functions *)
ClearAll[myScaledTicks];
myScaledTicks[sf_, isf_][min_, max_, n_: 6, 6] :=
Module[major, minor,
major, minor = FindDivisions[isf@min, max, n] /. x_Rational :> N[x];
minor = Complement[Join @@ minor, major];
major =
sf[#], #,
0.01, 0.,
AbsoluteThickness[0.1]
& /@ major;
minor =
sf[#], Spacer[0, 0],
0.005, 0.,
AbsoluteThickness[0.1]
& /@ minor;
Join[major, minor]
];
Plot of OP's data:
Show[
curvePlot = ListPlot[curveData, PlotRange -> 200, 600, All,
AxesOrigin -> 200, 0, Frame -> True,
ScalingFunctions -> curveScale, curveScaleInv],
linePlot = ListPlot[lineData,
PlotRange -> 200, 600, All, PlotStyle -> PointSize[0],
AxesOrigin -> 200, 0, Filling -> Axis,
FillingStyle -> Thickness[Tiny],
ScalingFunctions -> lineScale, lineScaleInv],
FrameTicks ->
myScaledTicks[curveScale, curveScaleInv],
myScaledTicks[lineScale, lineScaleInv],
Automatic, Automatic,
FrameLabel -> "curve (units?)", "line (units?)", "x (units?)", None
]
answered Jun 30 at 18:16
Michael E2Michael E2
155k12 gold badges213 silver badges502 bronze badges
155k12 gold badges213 silver badges502 bronze badges
$begingroup$
Thank you for your knowledgeable help !
$endgroup$
– SOUser
Jul 1 at 1:41
$begingroup$
@SOUser You're welcome!
$endgroup$
– Michael E2
Jul 1 at 3:26
add a comment |
$begingroup$
Thank you for your knowledgeable help !
$endgroup$
– SOUser
Jul 1 at 1:41
$begingroup$
@SOUser You're welcome!
$endgroup$
– Michael E2
Jul 1 at 3:26
$begingroup$
Thank you for your knowledgeable help !
$endgroup$
– SOUser
Jul 1 at 1:41
$begingroup$
Thank you for your knowledgeable help !
$endgroup$
– SOUser
Jul 1 at 1:41
$begingroup$
@SOUser You're welcome!
$endgroup$
– Michael E2
Jul 1 at 3:26
$begingroup$
@SOUser You're welcome!
$endgroup$
– Michael E2
Jul 1 at 3:26
add a comment |
$begingroup$
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
curvePlot = ListPlot[
curveData
, PlotRange -> 200, 600, All
, AxesOrigin -> 200, 0
, Frame -> True, True, True, False
];
linePlot = ListPlot[
lineData.DiagonalMatrix[1, 40000]
, PlotRange -> 200, 600, All
, PlotStyle -> PointSize[0]
, AxesOrigin -> 200, 0
, Frame -> False, False, False, True
, Filling -> Axis
, FillingStyle -> Thickness[Tiny]
];
Show[curvePlot, linePlot]
$endgroup$
add a comment |
$begingroup$
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
curvePlot = ListPlot[
curveData
, PlotRange -> 200, 600, All
, AxesOrigin -> 200, 0
, Frame -> True, True, True, False
];
linePlot = ListPlot[
lineData.DiagonalMatrix[1, 40000]
, PlotRange -> 200, 600, All
, PlotStyle -> PointSize[0]
, AxesOrigin -> 200, 0
, Frame -> False, False, False, True
, Filling -> Axis
, FillingStyle -> Thickness[Tiny]
];
Show[curvePlot, linePlot]
$endgroup$
add a comment |
$begingroup$
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
curvePlot = ListPlot[
curveData
, PlotRange -> 200, 600, All
, AxesOrigin -> 200, 0
, Frame -> True, True, True, False
];
linePlot = ListPlot[
lineData.DiagonalMatrix[1, 40000]
, PlotRange -> 200, 600, All
, PlotStyle -> PointSize[0]
, AxesOrigin -> 200, 0
, Frame -> False, False, False, True
, Filling -> Axis
, FillingStyle -> Thickness[Tiny]
];
Show[curvePlot, linePlot]
$endgroup$
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
curvePlot = ListPlot[
curveData
, PlotRange -> 200, 600, All
, AxesOrigin -> 200, 0
, Frame -> True, True, True, False
];
linePlot = ListPlot[
lineData.DiagonalMatrix[1, 40000]
, PlotRange -> 200, 600, All
, PlotStyle -> PointSize[0]
, AxesOrigin -> 200, 0
, Frame -> False, False, False, True
, Filling -> Axis
, FillingStyle -> Thickness[Tiny]
];
Show[curvePlot, linePlot]
edited Jun 30 at 13:39
answered Jun 30 at 13:00
rhermansrhermans
22.4k4 gold badges41 silver badges107 bronze badges
22.4k4 gold badges41 silver badges107 bronze badges
add a comment |
add a comment |
$begingroup$
Try
Show[curvePlot, linePlot]
As you can see the scaling of your data should be adapted!
$endgroup$
add a comment |
$begingroup$
Try
Show[curvePlot, linePlot]
As you can see the scaling of your data should be adapted!
$endgroup$
add a comment |
$begingroup$
Try
Show[curvePlot, linePlot]
As you can see the scaling of your data should be adapted!
$endgroup$
Try
Show[curvePlot, linePlot]
As you can see the scaling of your data should be adapted!
answered Jun 30 at 12:56
Ulrich NeumannUlrich Neumann
11.8k7 silver badges19 bronze badges
11.8k7 silver badges19 bronze badges
add a comment |
add a comment |
$begingroup$
If you want a more automated version of @MiachelE2's answer, you can use the CombinePlots
function of the ForScience`
paclet (see below for instructions on how to install it) with the setting "AxesSides" -> "TwoY"
(see the documentation of the paclet for more details and examples):
<<ForScience`
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
curvePlot = ListPlot[
curveData,
PlotRange -> 200, 600, All,
AxesOrigin -> 200, 0,
Frame -> True,
FrameLabel -> "x axis", "curve (units?)"
]
linePlot = ListPlot[
lineData,
PlotRange -> 200, 600, All,
PlotStyle -> PointSize[0], Red,
AxesOrigin -> 200, 0,
Filling -> Axis,
FillingStyle -> Thickness[Tiny],
Frame -> True,
FrameLabel -> "x axis", "line (units?)",
FrameStyle -> Red
]
CombinePlots[curvePlot, linePlot, "AxesSides" -> "TwoY"]
Note how the FrameLabel
,FrameTicks
and FrameStyle
of the second plot were automatically moved to the right side
How to install the paclet
The current version (0.88.45) of the paclet can be installed by running
PacletInstall[
"https://github.com/MMA-ForScience/ForScience/releases/download/v0.88.45/ForScience-0.88.45.paclet"
]
$endgroup$
add a comment |
$begingroup$
If you want a more automated version of @MiachelE2's answer, you can use the CombinePlots
function of the ForScience`
paclet (see below for instructions on how to install it) with the setting "AxesSides" -> "TwoY"
(see the documentation of the paclet for more details and examples):
<<ForScience`
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
curvePlot = ListPlot[
curveData,
PlotRange -> 200, 600, All,
AxesOrigin -> 200, 0,
Frame -> True,
FrameLabel -> "x axis", "curve (units?)"
]
linePlot = ListPlot[
lineData,
PlotRange -> 200, 600, All,
PlotStyle -> PointSize[0], Red,
AxesOrigin -> 200, 0,
Filling -> Axis,
FillingStyle -> Thickness[Tiny],
Frame -> True,
FrameLabel -> "x axis", "line (units?)",
FrameStyle -> Red
]
CombinePlots[curvePlot, linePlot, "AxesSides" -> "TwoY"]
Note how the FrameLabel
,FrameTicks
and FrameStyle
of the second plot were automatically moved to the right side
How to install the paclet
The current version (0.88.45) of the paclet can be installed by running
PacletInstall[
"https://github.com/MMA-ForScience/ForScience/releases/download/v0.88.45/ForScience-0.88.45.paclet"
]
$endgroup$
add a comment |
$begingroup$
If you want a more automated version of @MiachelE2's answer, you can use the CombinePlots
function of the ForScience`
paclet (see below for instructions on how to install it) with the setting "AxesSides" -> "TwoY"
(see the documentation of the paclet for more details and examples):
<<ForScience`
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
curvePlot = ListPlot[
curveData,
PlotRange -> 200, 600, All,
AxesOrigin -> 200, 0,
Frame -> True,
FrameLabel -> "x axis", "curve (units?)"
]
linePlot = ListPlot[
lineData,
PlotRange -> 200, 600, All,
PlotStyle -> PointSize[0], Red,
AxesOrigin -> 200, 0,
Filling -> Axis,
FillingStyle -> Thickness[Tiny],
Frame -> True,
FrameLabel -> "x axis", "line (units?)",
FrameStyle -> Red
]
CombinePlots[curvePlot, linePlot, "AxesSides" -> "TwoY"]
Note how the FrameLabel
,FrameTicks
and FrameStyle
of the second plot were automatically moved to the right side
How to install the paclet
The current version (0.88.45) of the paclet can be installed by running
PacletInstall[
"https://github.com/MMA-ForScience/ForScience/releases/download/v0.88.45/ForScience-0.88.45.paclet"
]
$endgroup$
If you want a more automated version of @MiachelE2's answer, you can use the CombinePlots
function of the ForScience`
paclet (see below for instructions on how to install it) with the setting "AxesSides" -> "TwoY"
(see the documentation of the paclet for more details and examples):
<<ForScience`
curveData, lineData = Import["https://pastebin.com/raw/SEg5tThi", "RawJSON"];
curvePlot = ListPlot[
curveData,
PlotRange -> 200, 600, All,
AxesOrigin -> 200, 0,
Frame -> True,
FrameLabel -> "x axis", "curve (units?)"
]
linePlot = ListPlot[
lineData,
PlotRange -> 200, 600, All,
PlotStyle -> PointSize[0], Red,
AxesOrigin -> 200, 0,
Filling -> Axis,
FillingStyle -> Thickness[Tiny],
Frame -> True,
FrameLabel -> "x axis", "line (units?)",
FrameStyle -> Red
]
CombinePlots[curvePlot, linePlot, "AxesSides" -> "TwoY"]
Note how the FrameLabel
,FrameTicks
and FrameStyle
of the second plot were automatically moved to the right side
How to install the paclet
The current version (0.88.45) of the paclet can be installed by running
PacletInstall[
"https://github.com/MMA-ForScience/ForScience/releases/download/v0.88.45/ForScience-0.88.45.paclet"
]
edited Jul 1 at 16:34
answered Jul 1 at 11:17
Lukas LangLukas Lang
8,0141 gold badge10 silver badges32 bronze badges
8,0141 gold badge10 silver badges32 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f201265%2fcannot-overlay-because-listplot-does-not-draw-same-x-range-despite-the-same-plo%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
Try
Show
instead ofOverlay
$endgroup$
– Ulrich Neumann
Jun 30 at 11:33
$begingroup$
@UlrichNeumann Could you help to suggest more specifically how to use
show
in this circumstance ? Many thanks !$endgroup$
– SOUser
Jun 30 at 12:26