剪切坐标轴

一般的科学论文用图片可以用SciDraw在Mathematica上实现,有些特殊的功能,比如剪断坐标轴的,可以用下面方式:

ClearAll[snip]

snipCurve = 
  Graphics[{BezierCurve[{{0, -(1/2)}, {1/3, 0}, {-1/3, 0}, {0, 
       1/2}}]}];

snip[pos_?NumberQ, primitive_Graphics: snipCurve] := 
  snip[{pos}, primitive];

snip[pos_List, primitive_Graphics: snipCurve] := 
  Arrowheads[{Automatic, #, primitive} & /@ pos];

snip[pos_List, primitives_List] := 
  Arrowheads[
   Flatten /@ MapThread[{Automatic, ##} &, {pos, primitives}]];

snip[sizes_List, pos_List, primitives_List] := 
 Arrowheads[Flatten /@ Transpose[{sizes, pos, primitives}]]

data1 = {{1, 1.1}, {2, 1.5}, {3, 0.9}, {4, 2.3}, {5, 1.1}};
data2 = {{1, 1001.1}, {2, 1001.5}, {3, 1000.9}, {4, 1002.3}, {5, 
    1001.1}};
data3 = {{1, 8001.1}, {2, 8001.5}, {3, 8000.9}, {4, 8002.3}, {5, 
    8001.1}};

getMaxPadding[p_List] := 
 Map[Max, (BorderDimensions@
        Image[Show[#, LabelStyle -> White, Background -> White]] & /@ 
      p)~Flatten~{{3}, {2}}, {2}] + 1

p1 = ListPlot[data1, PlotRange -> All, Joined -> True, Mesh -> Full, 
   PlotStyle -> Red, 
   AxesStyle -> {{Arrowheads[.035(*here*), .035], 
      Directive[Black, 12]}, {snip[1], Directive[Black, 12]}}, 
   PlotRangePadding -> .2, ImagePadding -> {{50, 5}, {15, 5}}, 
   AspectRatio -> 1/3];

p2 = ListPlot[data2, PlotRange -> All, Joined -> True, Mesh -> Full, 
   PlotStyle -> Blue, Axes -> {False, True}, 
   AxesStyle -> {{None}, {snip[{0, 1}], Directive[Black, 12]}}, 
   PlotRangePadding -> .2, ImagePadding -> {{50, 15}, {3, 5}}, 
   AspectRatio -> 1/3];

p3 = ListPlot[data3, PlotRange -> All, Joined -> True, Mesh -> Full, 
   PlotStyle -> Magenta, Axes -> {False, True}, 
   AxesStyle -> {{None}, {snip[{Automatic, .035}, {0, 
        1}, {snipCurve, {}}], Directive[Black, 12]}}, 
   PlotRangePadding -> .2, ImagePadding -> {{50, 15}, {3, 5}}, 
   AspectRatio -> 1/3];

output = Column[{p3, p2, p1} /. 
   Graphics[x__] :> 
    Graphics[x, ImagePadding -> getMaxPadding[{p1, p2, p3}], 
     ImageSize -> 600]]


Export["testOutputSnipAxis.png", output]



### 调整坐标轴设置以改善曲线识别效果 为了提高机器学习模型对于不同坐标系下曲线的鲁棒性和准确性,可以采取多种策略来调整坐标轴设置。这些方法旨在增强数据表示的一致性并减少因坐标变换带来的负面影响。 #### 数据标准化处理 通过将所有样本映射到相同的尺度范围,能够有效消除由于原始坐标的差异而导致的学习偏差。常用的方法是对每条曲线上各点的位置应用零均值单位方差规范化: \[ X' = \frac{X-\mu}{\sigma} \] 这里 \(X\) 表示原坐标位置,\(μ\) 是该维度上的平均数,而 \(σ\) 则代表标准差[^1]。 #### 不变性特性利用 考虑到不变性的概念——即推理过程中的参数不随具体输入改变而在训练阶段允许更新权重矩阵——可以在构建神经网络架构时引入特定机制确保某些层具备平移、旋转或其他几何转换下的稳定响应。例如卷积操作天然拥有局部感受野和平滑滤波器核的设计使其对小幅度位移具有一定容忍度;池化单元进一步增强了这种性质。 #### 几何变换扩充 增加额外的数据扩增手段如随机缩放、剪切以及仿射变形等预处理步骤有助于扩大训练集多样性从而提升泛化能力。这不仅限于简单的线性变换还包括非刚体形变模拟真实世界物体可能经历的各种复杂运动模式[^3]。 ```python import numpy as np from skimage import transform def augment_data(image, scale_range=(0.8, 1.2), rotation_angle=15): """Apply random scaling and rotation to an input image.""" tform = transform.AffineTransform( scale=tuple(np.random.uniform(*scale_range, size=2)), rotation=np.deg2rad(rotation_angle * (np.random.rand() - 0.5)) ) augmented_image = transform.warp(image, inverse_map=tform.inverse) return augmented_image ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值