Skip to content

Conversation

@joa-quim
Copy link
Member

They aren't really spheres but circles in 3D plots.

This is mostly a Claude.ai creation but a one that needed a lot of baby-sitting development.

Claude picked -SQ for this option and I honestly couldn't think of a better alternative, though -Sq is a decorated line and -SQ has nothing to do with it. Ideas for a better syntax are welcome. The following is the summary prepared by Claude


● Summary of -SQ Sphere Symbol Option

  Basic Syntax:
  -SQ<size>[c|i|p][+a<azimuth>][+e<elevation>][+f][+n]

  Description:
  The -SQ option plots a 3-D sphere symbol with diameter <size>. The sphere is rendered with a radial gradient shading from white at the light source position to the fill color (specified by -G) at the opposite side, creating a realistic 3-D appearance.

  Size Units:
  - Default unit: cm (centimeters)
  - Supported units: c (cm), i (inches), p (points)

  Modifiers:
  - +a - Set light source azimuth angle [default: 0°, from the right]
  - +e - Set light source elevation angle [default: 90°, perpendicular to viewing plane]
  - +f - Use flat/constant fill color (disables gradient shading)
  - +n - Draw outline only with no fill

  Fill and Outline:
  - Fill color: Specified by -G [default: black if not specified]
  - Outline: Controlled by -W (pen color, width, style)
  - Without -G and without +n, the sphere defaults to black fill

The +a and +e are not working correctly and I'm not even sure that we should have them. Opinions?

A low imagination example (used in the learning work) is:

echo 3 3 3 | gmt plot3d -R0/6/0/6/0/6 -JX10c -JZ4c -p135/45 -SQ2c -W0.2p,red -Ba -Bz -png lixo
lixo

They aren't really spheres but circles in 3D plots.

This is mostly a Claude.ai creation but a one that needed a lot of baby-sitting development.
@joa-quim joa-quim requested a review from a team December 21, 2025 23:18
Copy link
Member

@Esteban82 Esteban82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great feature!!!

It worked on my pc.

Just some comments.

  • Is it needed to include this feature in psxy.c?
  • The simulate shading does not affect the outline, right?

@joa-quim
Copy link
Member Author

I wondered about psxy.c too but this is a (pseudo) 3D feature so don't see the interest of it in there where we can do almost all of this with circles (except gradient).

The outline is controlled by -W so no shadings in it (and this was a BIG fight with Claude to make it do that).

@Esteban82
Copy link
Member

I wondered about psxy.c too but this is a (pseudo) 3D feature so don't see the interest of it in there where we can do almost all of this with circles (except gradient).

The outline is controlled by -W so no shadings in it (and this was a BIG fight with Claude to make it do that).

Ok. Fine by me.

About the letter (-SQ) I think that the capital P would be better. The lowercase p is for points.

@Esteban82 Esteban82 added enhancement Improving an existing feature add-changelog Add PR to the changelog labels Dec 22, 2025
@joa-quim
Copy link
Member Author

Yes, that's a good idea.

@Esteban82
Copy link
Member

Ok. I will I modify the code.

@Esteban82
Copy link
Member

Looks fine. Do you forget to update the psxy.c file?

@Esteban82
Copy link
Member

Looks fine. But, do you forget to update the psxy.c file?

char symbol_type, txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""}, txt_c[GMT_LEN256] = {""}, txt_d[GMT_LEN256] = {""};
char text_cp[GMT_LEN256] = {""}, diameter[GMT_LEN32] = {""}, *c = NULL;
static char *allowed_symbols[2] = {"~=-+AaBbCcDdEefGgHhIiJjMmNnpqRrSsTtVvWwxy", "=-+AabCcDdEefGgHhIiJjMmNnOopqRrSsTtUuVvWwxy"};
static char *allowed_symbols[2] = {"~=-+AaBbCcDdEefGgHhIiJjMmNnpQqRrSsTtVvWwxy", "=-+AabCcDdEefGgHhIiJjMmNnOopQqRrSsTtUuVvWwxy"};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, but should I replace here the Q with P?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so.

@joa-quim
Copy link
Member Author

Don't do it. There are more things to change. And psxy ill not receive this option

@joa-quim
Copy link
Member Author

@seisman can you please add the test/psxyz/sphere.sh PS to DVC?

@seisman
Copy link
Member

seisman commented Dec 25, 2025

I've added the baseline image to DVC, but currently it has a vertical axis on the left, should it be a 3D basemap instead?

sphere

@github-actions
Copy link
Contributor

github-actions bot commented Dec 25, 2025

Summary of changed images

This is an auto-generated report of images that have changed on the DVC remote

Status Path
modified test/baseline/psxyz/

Image diff(s)

Details

Added images

Modified images

Path Old New

Report last updated at commit e544ec1

Comment on lines +281 to +282
GMT_Usage (API, 3, "+a Set light source azimuth [0, from the right].");
GMT_Usage (API, 3, "+e Set light source elevation [90, perpendicular to viewing plane].");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does +a/+e really work? I tried to plot a sphere with -Sc1c+a90+e10 and expect to see the white light near the north edge, but it gives me:

Image

Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@joa-quim
Copy link
Member Author

The vertical bar in the example actually reveals a bug in the implementation. Modern and Classic modes are not giving the same thing. Whilst modern mode works:

echo 3 3 3 | gmt psxyz -R0/6/0/6/0/6 -JX10c -JZ4c -p135/45 -SP2c -Gblue -W0.2p,red -Ba -Bz -png lixo

the classic somehow screw the axis and shows only that vertical bar.

echo 3 3 3 | gmt psxyz -R0/6/0/6/0/6 -JX10c -JZ4c -p135/45 -SP2c -Gblue -W0.2p,red -Ba -Bz -P > lixo.ps

@joa-quim
Copy link
Member Author

Does +a/+e really work?

No. I mentioned that in my first post. And asked opinions if it really worth to exist as option. I still think yes but meanwhile other things came up and I left them in the state they are.

@seisman
Copy link
Member

seisman commented Dec 25, 2025

Does +a/+e really work?

No. I mentioned that in my first post. And asked opinions if it really worth to exist as option. I still think yes but meanwhile other things came up and I left them in the state they are.

I think they're useful and should be implemented.

@joa-quim
Copy link
Member Author

I updated the test. Turns out that the vertical bar issue is independent of the changes in this PR. See #8845

@joa-quim
Copy link
Member Author

I tried to plot a sphere with -SP1c+a90+e10 and expect to see the white light near the north edge,

Is it? I'm not even so sure on what to expect. I would say that the expectation would be to have the bright point at 45º lat when looking, for example from -p180/45, and that because we also have to take into account the elevation of the perspective view. This means that illumination should only be allowed to come from the illuminated hemisphere (plus some tolerance for the same reason that we still have day light even after sunset).

Oddly the PS seem right but conversion to raster flips spheres upside-down.
@joa-quim
Copy link
Member Author

joa-quim commented Dec 25, 2025

Fixed (I think) the +e and +a options. But a very strange thing decided joining the party. The psconvert part flips the spheres upsisde-down. This is flipped but the PS is correct (and the PDF too).

echo 3 3 3 | build\src\gmt psxyz -R0/6/0/6/0/6 -JX10c -JZ4c -p180/45 -SP4c+e90+a180 -Gblue -W0.2p,red -Ba -Bza -png lixo
lixo

@Esteban82
Copy link
Member

echo 3 3 3 | build\src\gmt psxyz -R0/6/0/6/0/6 -JX10c -JZ4c -p180/45 -SP4c+e90+a180 -Gblue -W0.2p,red -Ba -Bza -png lixo

I got the same result.

@joa-quim
Copy link
Member Author

I will merge this PR as is since this flipping issue seems even a Ghostscript thing. Will try to investigate it later.

@joa-quim joa-quim merged commit 65f2d39 into master Dec 26, 2025
10 of 14 checks passed
@joa-quim joa-quim deleted the PS-spheres branch December 26, 2025 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-changelog Add PR to the changelog enhancement Improving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants