找回密码
 注册
Simdroid-非首页
查看: 501|回复: 9

[图形图像] 如何绘制双纵轴坐标图形?

[复制链接]
发表于 2011-5-18 10:34:51 | 显示全部楼层 |阅读模式 来自 甘肃兰州
本帖最后由 FreddyMusic 于 2011-5-19 12:33 编辑

现在需要作出这样一张图,如附件
数据共用一个横轴,但纵轴不同。不能直接让某一组数据直接乘一个常数以画到一起。
麻烦大家看一下。本版有过关于双坐标轴的讨论,但好像跟这个情况都不太一样,故再此一问。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
发表于 2011-5-18 10:54:32 | 显示全部楼层 来自 LAN
Simdroid开发平台
1# jimogsh
参考这个

  1. Plot[{Sin[x], Cos[x]}, {x, -1, 1},
  2. Frame -> {{True, True}, {True, False}},
  3. FrameTicks -> {{Automatic, {{-0.5, 5}, {0, 10}, {0.5,
  4.       15}}}, {Automatic, None}},
  5. FrameLabel -> {{"Left", "Right"}, {None, None}}]
复制代码
回复 不支持

使用道具 举报

 楼主| 发表于 2011-5-18 15:05:02 | 显示全部楼层 来自 甘肃兰州
2# guocong89
不错,我看看去。谢谢了
回复 不支持

使用道具 举报

发表于 2011-5-18 15:07:51 | 显示全部楼层 来自 LAN
3# jimogsh
你应该今年毕业了吧,接下来干啥呢
回复 不支持

使用道具 举报

 楼主| 发表于 2011-5-18 15:09:38 | 显示全部楼层 来自 甘肃兰州
4# guocong89
看图啊,我就分析树木年轮呢。。保研了
你说的那还是以左边的轴的画的吧,右边的轴是手动放上去的,那怎么对的准啊?我这个数据是散点的,右边的轴不好对啊。
回复 不支持

使用道具 举报

发表于 2011-5-18 15:15:51 | 显示全部楼层 来自 LAN
5# jimogsh
右边那个建了一个映射关系,这个确实得慢慢调调
回复 不支持

使用道具 举报

发表于 2011-5-18 19:23:58 | 显示全部楼层 来自 黑龙江哈尔滨
origin 做这个要更方便吧
回复 不支持

使用道具 举报

发表于 2011-5-18 20:55:15 | 显示全部楼层 来自 清华大学
本帖最后由 sunt05 于 2011-5-18 20:57 编辑

试试这个~
可以参考这个帖子:
https://groups.google.com/d/msg/comp.soft-sys.math.mathematica/CKE9Ghn43x8/F1_JnIbCYjsJ

  1. Clear[TwoAxisDateListPlot];

  2. TwoAxisDateListPlot[f_List, g_List, opts : OptionsPattern[]] :=
  3. Module[{p1, p2, fm, fM, gm, gM, old, new, newg},
  4.   p1 = DateListPlot[f, Axes -> True, Frame -> False,
  5.     PlotRange -> Automatic];
  6.   p2 = DateListPlot[g, Axes -> True, Frame -> False,
  7.     PlotRange -> Automatic];
  8.   {fm, fM} = AbsoluteOptions[p1, PlotRange][[1, 2, 2]];
  9.   {gm, gM} = AbsoluteOptions[p2, PlotRange][[1, 2, 2]];
  10.   old = AbsoluteOptions[p2, Ticks][[1, 2, 2]];
  11.   new = Flatten[{Rescale[First[#1], {gm, gM}, {fm, fM}], Rest[#1]},
  12.       1] & /@ old;
  13.   newg = {#[[1]], Rescale[#[[2]], {gm, gM}, {fm, fM}]} & /@ g;
  14.   DateListPlot[{f, newg}, Axes -> False, Frame -> True,
  15.    FrameTicks -> {Automatic, Automatic, None, new},
  16.    PlotRange -> {fm, fM}, opts]]

  17. Clear[TwoAxisReverseDateListPlot];

  18. TwoAxisReverseDateListPlot[f_List, g_List, opts : OptionsPattern[]] :=
  19.   Module[{p1, p2, fm, fM, gm, gM, old, new, newg},
  20.   p1 = DateListPlot[f, Axes -> True, Frame -> False,
  21.     PlotRange -> Automatic];
  22.   p2 = DateListPlot[g, Axes -> True, Frame -> False,
  23.     PlotRange -> Automatic];
  24.   {fm, fM} = AbsoluteOptions[p1, PlotRange][[1, 2, 2]];
  25.   {gm, gM} = AbsoluteOptions[p2, PlotRange][[1, 2, 2]];
  26.   old = AbsoluteOptions[p2, Ticks][[1, 2, 2]];
  27.   new = Flatten[{fM + fm - Rescale[First[#1], {gm, gM}, {fm, fM}],
  28.        Rest[#1]}, 1] & /@ old;
  29.   newg = {#[[1]], fM + fm - Rescale[#[[2]], {gm, gM}, {fm, fM}]} & /@
  30.     g;
  31.   DateListPlot[{f, newg}, Axes -> False, Frame -> True,
  32.    FrameTicks -> {Automatic, Automatic, None, new},
  33.    PlotRange -> {fm, fM}, opts]]

  34. TwoAxisReverseDateListPlot[f_List, g_List, r_,
  35.   opts : OptionsPattern[]] :=
  36. Module[{p1, p2, gg, pg2, m, M, fm, fM, gm, gM, ggm, ggM, old, new,
  37.    newg}, p1 =
  38.    DateListPlot[f, Axes -> True, Frame -> False,
  39.     PlotRange -> Automatic];
  40.   gg = g;
  41.   gg[[All, 2]] /= 1 - r;
  42.   p2 = DateListPlot[g, Axes -> True, Frame -> False,
  43.     PlotRange -> Automatic];
  44.   pg2 = DateListPlot[gg, Axes -> True, Frame -> False,
  45.     PlotRange -> Automatic];
  46.   {fm, fM} = AbsoluteOptions[p1, PlotRange][[1, 2, 2]];
  47.   {m, M} = {fm, 1/r fM};
  48.   {gm, gM} = AbsoluteOptions[p2, PlotRange][[1, 2, 2]];
  49.   {ggm, ggM} = AbsoluteOptions[pg2, PlotRange][[1, 2, 2]];
  50.   old = AbsoluteOptions[pg2, Ticks][[1, 2, 2]];
  51.   new = Flatten[{(M + m - Rescale[First[#1], {ggm, ggM}, {m, M}]),
  52.        Rest[#1]}, 1] & /@ old;
  53.   newg = {#[[
  54.        1]], (M + m - (1 - r) Rescale[#[[2]], {gm, gM}, {m, M}])} & /@
  55.     g;
  56.   DateListPlot[{f, newg}, Axes -> False, Frame -> True,
  57.    FrameTicks -> {Automatic, new, None, All}, PlotRange -> {m, M},
  58.    opts]]
复制代码
回复 不支持

使用道具 举报

 楼主| 发表于 2011-5-19 09:40:46 | 显示全部楼层 来自 甘肃兰州
话说 我们师兄就是用origin的,我想先用Mathematica试试来着
回复 不支持

使用道具 举报

发表于 2011-5-23 13:12:35 | 显示全部楼层 来自 黑龙江哈尔滨
话说 我们师兄就是用origin的,我想先用Mathematica试试来着
jimogsh 发表于 2011-5-19 09:40


试试这个?

http://wnsl.physics.yale.edu/levelscheme/
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-4-26 23:53 , Processed in 0.040252 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表