sciapp / gr

GR framework: a graphics library for visualisation applications
Other
328 stars 54 forks source link

There might be some confusion about gr_cellarray and gks_cellarray ? #91

Closed kojix2 closed 4 years ago

kojix2 commented 4 years ago

Hello. I'm new to gr-framework. I doubt that something is wrong with gr_cellarray and gks_cellarray.

gr.c https://github.com/sciapp/gr/blob/494f193a9120957cb85222727260da2de70682f2/lib/gr/gr.c#L1720-L1723

https://github.com/sciapp/gr/blob/494f193a9120957cb85222727260da2de70682f2/lib/gr/gr.c#L1734

https://github.com/sciapp/gr/blob/494f193a9120957cb85222727260da2de70682f2/lib/gr/gr.c#L1739

working example https://github.com/sciapp/gr/issues/39#issuecomment-301684973

gr_cellarray(-0.5, 3.5, 3.5, -0.5, 4, 4, 1, 1, 4, 4, colia);

The direction of the Y axis may be opposite for gr and gks. Even so, it seems somehow inconsistent.

I'm sorry if I'm wrong.

FlorianRhiem commented 4 years ago

Hello, the gr_ and gks_ sets of functions are for two libraries with different aims:

As a result, there are a few cases where the APIs may look very similar but may behave differently. In general, I would recommend sticking to the gr API for your code.

kojix2 commented 4 years ago

Thank you @FlorianRhiem.

I use GR modules from Ruby and Julia. I don't use GKS. But look at the example below.

https://github.com/sciapp/gr/issues/39

gr_cellarray(-0.5, 3.5, 3.5, -0.5, 4, 4, 1, 1, 4, 4, colia);

ymin is greater than ymax. Isn't this a little strange?

FlorianRhiem commented 4 years ago

Not really, in this case the top row of the image is positioned at -0.5 and the bottom row is positioned at 3.5, which means that the image will appear upside-down. I think this was the aim in the example. Alternatively you could reverse the image rows themselves instead of swapping ymin and ymax.

kojix2 commented 4 years ago

Hmm. I still don't understand. I feel something is wrong.

image

image

FlorianRhiem commented 4 years ago

I think the problem there is that you're trying to draw a cellarray between xmin=-0.5 and xmax=-0.5, so it would have a width of 0 and would be invisible.

kojix2 commented 4 years ago

I see. Now I understand. Sorry for the trouble you. Thank you.