Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing plots to png unusable - Exporting direct graphics #1215

Closed
abhip0595 opened this issue Nov 25, 2021 · 9 comments
Closed

Writing plots to png unusable - Exporting direct graphics #1215

abhip0595 opened this issue Nov 25, 2021 · 9 comments

Comments

@abhip0595
Copy link

probably the same issue. I am trying to export plots from direct graphics to png using write_png but output is unusable.
I am using WSL - Ubuntu 20.04.3 LTS
Screenshot 2021-11-25 205748
example program I used: colorfill.pro
code:

PRO 

- [ ] 

- [ ] ColorFill

   ; The data to plot.
   x = Findgen(101)
   y = 4 * Sin(x * !DtoR) / Exp( (x-15) / 25.)

   ; Initial data plot.
   cgDisplay, 750, 500, Title='Filled Area Under a Curve'
   cgPlot, x, y, Background=background, Color='red', /NODATA

   ; Set up the polygon to fill with color.
   low = 20
   high = 45
   lowY  = 4 * Sin(low * !DtoR) / Exp( (low-15) / 25.)
   highY = 4 * Sin(high * !DtoR) / Exp( (high-15) / 25.)
   indices = Value_Locate(x, [low, high])
   lowIndex = indices[0]
   highIndex = indices[1]
   IF x(lowIndex) LT low THEN lowIndex = lowIndex + 1
   IF x(highIndex) GT high THEN highIndex = highIndex - 1

   ; Fill the polygon with color.
   xpoly = [         low,  low, x[lowIndex:highIndex],  high,         high]
   ypoly = [!Y.CRange[0], lowY, y[lowIndex:highIndex], highY, !Y.CRange[0]]
   cgColorFill, xpoly, ypoly, Color='dodger blue'

   ; Repair plot damage caused by the polygon fill and spruce up the plot.
   cgPlotS, xpoly, ypoly, Color='navy', Thick=2
   cgPlot, x, y, /NoData, /NoErase
   cgOPlot, x, y, Color='red', Thick=3

   ;Added write_png to export plot
   write_png,'test.png',tvrd(/true,/order)

END
@abhip0595 abhip0595 changed the title Writing plots to png - Exporting direct graphics Writing plots to png unusable - Exporting direct graphics Nov 25, 2021
@GillesDuvert
Copy link
Contributor

@abhip0595 this works for me very well with today's GDL. Unless you built GDL from scratch, yours (focal fossa) is probably still gdl.0.9.9, this explains that.

@abhip0595
Copy link
Author

I have installed the latest build 1.0.1
followed steps from https://github.com/gnudatalanguage/gdl/wiki/GDL-on-Linux using the script build_gdl.sh

image

I rolled back to previous version (v1.0.0), where I get usable png (plots exported).

the plots are fine in the graphics window but when I try to export (write_png), the image is unusable in (gdl v1.0.1).

@GillesDuvert
Copy link
Contributor

Thanks @abhip0595
OK, so 1.0 works and 1.0.1 is KO.
As there have been lots of changes (for the best) in the recent weeks on the subject of image formats, I guess 1.0.1 is in need of a replacement.
If 1.0 suits you, then keep it and perhaps have a new look when 1.0.2 appears.

@slayoo
Copy link
Member

slayoo commented Dec 1, 2021

@GillesDuvert @acoulais @pjb7687 @ogressel should we then release 1.0.2?

@pjb7687
Copy link
Member

pjb7687 commented Dec 1, 2021

Makes sense to me. Just ping me when you are ready and I will release 1.0.2.

@ogressel
Copy link
Contributor

ogressel commented Dec 2, 2021

Not sure what the general release strategy is (how often?, what requirements?, ...).

Currently, I am trying to incrementally improve/extend the functionality of the HDF5 module, which is still "read only", though it should cover most real-world use cases by now, notably excluding

  1. reading "enum" data types (who uses these?),
  2. partial reads from "compound" types (this might be useful, and maybe not too hard to implement)
  3. non-scalar data spaces with compounds (for this I'd need to better understand DStructGDL descriptors/instances, I reckon)

The low-level write routines should in principle be very similar to the read routines, once the "H5T_idl_create" routine is in place.

@GillesDuvert
Copy link
Contributor

@ogressel you could create a discussion forum for GDL/HDF5 users (or potential users) to get a roadmap, but at the moment you seem the best person to improve and extent the HDF5 module.
We will try to make much more frequent releases than in the past, 1.0.2 this time, making a note in the release comments that there is improvement continuing on HDF5 is not only necessary but may attract attention from potential users.

@abhip0595
Copy link
Author

firstly, thank you for looking at the issue. I look forward to new release.
I am using a work around for the time being: SET_PLOT, 'PS' - this way i can still get usable plots for my paper.

once again thank you.

@GillesDuvert
Copy link
Contributor

@pjb7687 on my side, #1217 is clearly not ready, so unless somebody test #1041 and deem it OK, one can make a new release from current (quite adequate) state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants