# Problem with the cross section

**URL:** <https://forum.generic-mapping-tools.org/t/problem-with-the-cross-section/4594>\
**Category:** PyGMT Q&A\
**Created:** [January 12, 2024, 1:31pm UTC](https://forum.generic-mapping-tools.org/t/problem-with-the-cross-section/4594 "2024-01-12T13:31:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![konstak98](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/konstak98/32/3865_2.png) [@konstak98](https://forum.generic-mapping-tools.org/u/konstak98)\
**Post date:** [January 12, 2024, 1:31pm UTC](https://forum.generic-mapping-tools.org/t/problem-with-the-cross-section/4594/1 "2024-01-12T13:31:02Z")

</div>

I guess I have a problem with pygmt.project

```
import pygmt

fig = pygmt.Figure()

pygmt.makecpt(cmap="red,green,blue", series="0,70,300,10000", output="quakes.cpt")

fig.coast(

    region=[25.0, 25.5, 35.0, 35.5],

    projection="M4i",

    frame=["xa2g2", "ya2g2pf3", '+t"Sumatra"'],

    land="lightbrown",

    shorelines="0.25p",

)

fig.plot(data="crosssection.dat", pen="faint", style="c0.15", cmap="quakes.cpt")

fig.plot(x=[25.140133, 25.363331], y=[35.175001, 35.109202], projection="M", pen=2)

fig.text(x=25.140133, y=35.175001, text="A", font="15,Helvetica")

fig.text(x=25.363331, y=35.109202, text="A'", font="15,Helvetica")

pygmt.project(

    data="crosssection.dat",

    unit=True,

    center="25.140133/25.363331",

    endpoint="25.363331/35.109202",

    convention="pz",

    width=[0, 10],

    outfile="cross_AA.dat",

)

fig.basemap(

    projection="X10/-6",

    region=[0, 21.57331168885003, 0, 30],

    frame=['xafg100+l"Distance"', 'yafg50+l"Depth"', "WSen"],

    yshift=1,

)

fig.plot(data="cross.dat", projection="X", style="c0.2", pen=1, color="red")

fig.text(x=10, y=10, text="A", font="13,Helvetica")

fig.text(x=490, y=10, text="B", font="13,Helvetica")

fig.savefig(fname="Arkaloxori.png")

fig.show()

```

[crosssection.dat](https://forum.generic-mapping-tools.org/uploads/short-url/eGekgO3nh25b0stzj7rOmkrL2Kc.dat) (30.3 KB)

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [January 12, 2024, 3:54pm UTC](https://forum.generic-mapping-tools.org/t/problem-with-the-cross-section/4594/2 "2024-01-12T15:54:04Z")

</div>

> [@konstak98](#):
>
> `fig.plot(data="cross.dat"`

???

---

<div class="post-metadata">

**Author:** ![konstak98](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/konstak98/32/3865_2.png) [@konstak98](https://forum.generic-mapping-tools.org/u/konstak98)\
**Post date:** [January 12, 2024, 5:27pm UTC](https://forum.generic-mapping-tools.org/t/problem-with-the-cross-section/4594/3 "2024-01-12T17:27:29Z")

</div>

I think i have problem to understand the width and of course with the subplot of the plots.

```python
import pygmt

fig = pygmt.Figure()

# Make color palette for topography

pygmt.makecpt(cmap='geo', series='-500/2000/100', continuous=True)

# Plot high-resolution topography

region = [25.0, 25.5, 35.0, 35.5] # Replace with the appropriate region for your data

# Add coastlines to the map

fig.grdimage(

    grid='@earth_relief_01s', # Change to 30m for higher resolution

    region=region,

    projection='M4i',

    shading=True,

    frame=True

)

fig.plot(data="crosssection.dat", pen="faint", style="c0.15", cmap="quakes.cpt")

fig.plot(x=[25.14, 25.36], y=[35.17, 35.10], projection="M", pen=2)

fig.text(x=25.14, y=35.17, text="A", font="15,Helvetica")

fig.text(x=25.36, y=35.10, text="A'", font="15,Helvetica")

pygmt.project(

    data="crosssection.dat",

    unit=True,

    center=[25.14, 35.17],

    endpoint=[25.36, 35.10],

    convention="pz",

    width=[0, 2],

    outfile="cross_AA.dat",

)

fig.basemap(

    projection="X10/-6",

    region=[0, 21.57331168885003, 0, 30],

    frame=['xafg100+l"Distance"', 'yafg50+l"Depth"', "WSen"],

    yshift=-5,

)

fig.plot(data="cross_AA.dat", projection="X", style="c0.2", pen=1, color="red")

fig.text(x=10, y=10, text="A", font="13,Helvetica")

fig.text(x=490, y=10, text="B", font="13,Helvetica")

fig.savefig(fname="Arkaloxori.pdf")

fig.show()

```

[crosssection.dat](https://forum.generic-mapping-tools.org/uploads/short-url/eGekgO3nh25b0stzj7rOmkrL2Kc.dat) (30.3 KB)

---

<div class="post-metadata">

**Author:** ![EJFielding](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/ejfielding/32/82_2.png) [@EJFielding](https://forum.generic-mapping-tools.org/u/EJFielding)\
**Post date:** [May 8, 2024, 5:14am UTC](https://forum.generic-mapping-tools.org/t/problem-with-the-cross-section/4594/4 "2024-05-08T05:14:37Z")

</div>

It is not clear what kind of plot you are trying to make. Do you want to plot the cross-section in a 3-D perspective view under the topography? Or do you want to show the topographic map in map view with the cross-section plotted on top?
