bugGNU Octave - Bugs: bug #62130, print with transparency, pdf ok...

 
 

bug #62130: print with transparency, pdf ok but pdflatex fails

Submitter:  George Apostolopoulos <gapost>
Submitted:  Wed 02 Mar 2022 11:25:20 AM UTC
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Thu 02 Jun 2022 12:06:34 PM UTC, comment #4: 

Setting the release target to "dev" because any change will likely go to the default branch.

Please, feel free to close if you think that it's not worth the effort to implement support for transparency in the direct toolchain to .pdf (omitting the .svg toolchain).

Markus M├╝tzel <mmuetzel>
Project Member
Thu 03 Mar 2022 09:28:08 AM UTC, comment #3: 

Hi, thanks for your reply.

The latex interpreter support is cool! I realized I had to install dvisvgm on my system and now it works for me.

The quality of final pdf is very good and solves a lot of other problems too, e.g. legend size/positioning which I usually had to adjust by hand with pdflatex.

Best regards
George

George Apostolopoulos <gapost>
Wed 02 Mar 2022 09:47:14 PM UTC, comment #2: 

Yes, as you discovered, the only tool chain that supports transparency for vector outputs is based on conversion of svg. Using it to produce the raw pdf as you propose in comment #1 could be envisaged. Another alternative, if you can live with path rather than text, is to wait for the upcoming Octave 7 which will support the latex interpreter (using an external latex engine):

set (0, "defaultaxesticklabelinterpreter", "latex", "defaulttextinterpreter", "latex")
x=linspace(-1,1,101);
s = 0.15;
y1 = exp(-(x/s).^2/2);
y2 = 0.75*exp(-((x-0.3)/0.15).^2/2);
hold on
h = fill([x 1 -1],[y1 0 0],'b', ...
  'FaceAlpha',.3);
set(h,'EdgeAlpha',.3); # this line causes bug
fill([x 1 -1],[y2 0 0],'r', ...
  'FaceAlpha',.3);
hold off
box on
title('print -dpdfcrop -svgconvert')
print -dpdfcrop -svgconvert curves

Figure attached.

(file #52950)

Pantxo Diribarne <pantxo>
Project Member
Wed 02 Mar 2022 05:02:46 PM UTC, comment #1: 

I found a way to obtain the correct result with pdflatex.

Octave's print command with pdflatex/pdflatexstandalone options uses gl2ps_device = "pdfnotext" to produce the pdf file to be included in latex.

In the attached script file #52948 this is done with gl2ps_device="svgnotext" and then the svg is converted to pdf with octave's svgconvert program.

The obtained pdf file #52949 shows the transparency correctly and is smaller in size.

George Apostolopoulos <gapost>
Wed 02 Mar 2022 11:25:20 AM UTC, original submission:  

Printing figures with transparency sometimes produces incorrect results with pdflatex while pdf+svgconvert is ok.

Example 1: rectangles

clear
close('all')
rectangle("position", [0.2 0.3 0.6 0.4], "facecolor", "b", "FaceAlpha",.3)
rectangle("position", [0.3 0.2 0.4 0.6], "facecolor", "r", "FaceAlpha",.3)
axis([0 1 0 1])
box on
title('print -dpdfcrop -svgconvert')
print -dpdfcrop -svgconvert rectangles
title('print -dpdflatexstandalone -svgconvert')
print -dpdflatexstandalone -svgconvert rectangles-latex
[out, txt] = system ("pdflatex rectangles-latex.tex")

In the file produced with "-dpdflatexstandalone" the transparency does not come out right.

Example 2: fill

close('all')
clear
x=linspace(-1,1,101);
s = 0.15;
y1 = exp(-(x/s).^2/2);
y2 = 0.75*exp(-((x-0.3)/0.15).^2/2);
hold on
h = fill([x 1 -1],[y1 0 0],'b', ...
  'FaceAlpha',.3);
set(h,'EdgeAlpha',.3); # this line causes bug
fill([x 1 -1],[y2 0 0],'r', ...
  'FaceAlpha',.3);
hold off
box on
title('print -dpdfcrop -svgconvert')
print -dpdfcrop -svgconvert curves
title('print -dpdflatexstandalone -svgconvert')
print -dpdflatexstandalone -svgconvert curves-latex
[out, txt] = system ("pdflatex curves-latex.tex")

Again the file produced with "-dpdflatexstandalone" is not ok.

Note that the problem in Ex. 2 appears only when setting 'EdgeAlpha'.

Attached are the pdf files produced in my system (Ububtu 20.04).

I used firefox built-in pdf viewer to view the pdfs (some programs may interpret the files incorrectly).

George Apostolopoulos <gapost>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #52950:  curves.pdf added by pantxo (16KiB - application/pdf)
file #52948:  curves_latex_fix.m added by gapost (2KiB - text/x-objcsrc - A way to get transparency correctly with pdflatex)
file #52949:  curves-latex-fix.pdf added by gapost (18KiB - application/pdf - A way to get transparency correctly with pdflatex)
file #52945:  rectangles-latex.pdf added by gapost (18KiB - application/pdf)
file #52946:  curves.pdf added by gapost (10KiB - application/pdf)
file #52947:  curves-latex.pdf added by gapost (27KiB - application/pdf)
file #52944:  rectangles.pdf added by gapost (9KiB - application/pdf)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by pantxo (Updated the item)
  • -email is unavailable- added by gapost (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.

     

     

     

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-06-02 mmuetzel Release7.0.90 dev
    2022-03-02 pantxo Attached File- Added curves.pdf, #52950
        CategoryPlotting Plotting with OpenGL
    2022-03-02 gapost Attached File- Added curves_latex_fix.m, #52948
        Attached File- Added curves-latex-fix.pdf, #52949
    2022-03-02 gapost Attached File- Added rectangles.pdf, #52944
        Attached File- Added rectangles-latex.pdf, #52945
        Attached File- Added curves.pdf, #52946
        Attached File- Added curves-latex.pdf, #52947

    Back to the top


    Powered by Savane 3.9