sciapp / gr

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

GRM - contour and contourf seem to be displaced #117

Closed mantielero closed 4 years ago

mantielero commented 4 years ago

It looks like the plot is displaced to the bottom left (or that image is clipped in the top and the right). You can see the effect here and here.

IngoMeyer441 commented 4 years ago

The example image was probably generated with GR v0.48.0 (the latest version uses another font)? With our current version I get a correctly positioned image with similar C code: image

IngoMeyer441 commented 4 years ago

Contour plot:

image

mantielero commented 4 years ago

Even in your examples it can be seen that something funny is happenning. In the first picture, it looks like the contain is displaced to the right. In the second one, it looks like there is some clipping at the bottom and the top, but not on the left and the right. It looks like the major ticks where drawing white rectangle on top of the figure. I have updated to 0.49, and I get the attached figures.

On the other hand, you can see in the following pictures (by me, using 0.49) that it looks like the clipping is on the right and on top. contour_v0 49 0 contourf_v0 49

IngoMeyer441 commented 4 years ago

The input data for x and y are random numbers between -4 and 4. But in most cases the numbers -4 and 4 are not chosen by the random number generator (you only get slightly larger and smaller values). The contour and contourf functions use the actual input minimum and maximum but GRM rounds minimum and maximum to the nearest integer when drawing the coordinate system which is the reason for the white border and why it changes for every program run. So, the result you get is actually correct. But of course, the white border is quite disturbing. In order to remove it you can set adjust_xlim and adjust_ylim to 0:

image

mantielero commented 4 years ago

Understood. Thanks a lot.