# Transparent SciLab graph

**URL:** <https://scilab.discourse.group/t/transparent-scilab-graph/822>\
**Category:** Graphics and plotting\
**Created:** [February 17, 2025, 10:11pm UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822 "2025-02-17T22:11:27Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![heinznabielek](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@heinznabielek](https://scilab.discourse.group/u/heinznabielek)\
**Post date:** [February 17, 2025, 10:11pm UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/1 "2025-02-17T22:11:27Z")

</div>

How can I generate a transparent SciLab graph that I can superimpose over another image?

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [February 18, 2025, 4:18pm UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/2 "2025-02-18T16:18:08Z")

</div>

Hello Heinz,

In fact it is not possible within Scilab, but you can do this by exporting the graph as svg then edit the file e.g. with Inkscape.

S.

---

<div class="post-metadata">

**Author:** ![heinznabielek](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@heinznabielek](https://scilab.discourse.group/u/heinznabielek)\
**Post date:** [February 18, 2025, 9:17pm UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/3 "2025-02-18T21:17:18Z")

</div>

Yes. I had imported the Scilab svg into GIMP, touched the white background with the wand and exported png

---

<div class="post-metadata">

**Author:** ![philipp](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/philipp/32/53_2.png) [@philipp](https://scilab.discourse.group/u/philipp)\
**Post date:** [February 18, 2025, 10:19pm UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/4 "2025-02-18T22:19:09Z")

</div>

Hello Heinz,

> …True transparency is not possible within Scilab…

Yes, but if you only need the effect of overlapping colors, you may try the pixel\_drawing\_mode.

[https://help.scilab.org/docs/2025.0.0/en\_US/pixel\_drawing\_mode.html](https://help.scilab.org/docs/2025.0.0/en_US/pixel_drawing_mode.html)

Best regards,  
Philipp

---

<div class="post-metadata">

**Author:** ![heinznabielek](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@heinznabielek](https://scilab.discourse.group/u/heinznabielek)\
**Post date:** [February 18, 2025, 10:59pm UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/5 "2025-02-18T22:59:03Z")

</div>

I need to overlay attached image onto a geographical map. How can I do this in drawing mode?

 ![Bird Tracking](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/47dc165eaf74d534fb9b89b08a69279c530fe7cf.png)

---

<div class="post-metadata">

**Author:** ![philipp](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/philipp/32/53_2.png) [@philipp](https://scilab.discourse.group/u/philipp)\
**Post date:** [February 19, 2025, 5:38am UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/6 "2025-02-19T05:38:07Z")

</div>

OK, understood.

In general I would suggest to work completely within Scilab without export to svg and image processing software like gimp.  
Then you can do this without transparency at all.

It depends a little of the type of map you need.

version A:  
use Scilab toolbox: celestlab

> **[Scilab Module : CelestLab](https://atoms.scilab.org/toolboxes/celestlab)**
>
> CNES Space Mechanics Toolbox for Mission Analysis

Within this, there is a function to plot borders: `CL_plot_earthMap()`

However I think you will get only borders of coast lines (continents, islands, lakes)…not “in between states borders”.

Version B:  
load a map as an image via `imread()` …e.g from IPCV toolbox.  
Display the map with `Matplot()`

However this might become tricky, since you will have to deal with correct map projection if you want to overlay long/lat coordinates.  
Hint: Google search EPSG4326 and EPSG3857

 ![test_EPSG_4326_map](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/5f5b9baf3ab08f8c51102255abf6336890a75fff.png)

However, if you have all you need you can play with several axes …  
E.g:  
axis1: map pixel coordinates (right/top)  
axis 2: lat/long coordinates (left/bottom)

`newaxes()` is your friend here.

The image shows a combination of:

- map read via `imread()`
- borders used from `CL_plot_earthMap()` … (e.g.: coastal line)
- state border using `plot()` … data from [Germany Detailed Boundary: Free Vector Map - Cartography Vectors](https://cartographyvectors.com/map/917-germany-detailed-boundary), in this case the `germany-detailed-boundary_917.kml`

Best Regards,  
Philipp

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [February 19, 2025, 12:55pm UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/7 "2025-02-19T12:55:04Z")

</div>

OK, this has nothing to do with transparency. Just display the background, then plot something over it. As Philipp says using newaxes() can help.

S.

---

<div class="post-metadata">

**Author:** ![philipp](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/philipp/32/53_2.png) [@philipp](https://scilab.discourse.group/u/philipp)\
**Post date:** [February 20, 2025, 11:29pm UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/8 "2025-02-20T23:29:27Z")

</div>

Hello Heinz,

just to mention:

In principle it is possible to generate opaque graph images.

The image below was done in inkscape, by:

- loading a background image
- loading a Scilab generated diagram, saved as a RGBA image

To be precise, the graph was:

- generated using `plot()` command
- exported via `xs2png()` as an RGB image
- reloaded via IPCV `imread()` as a 3 channel matrix
- combined with an alpha channel (define white pixel = transparent)
- saved via IPCV `imwrite()`as an RGBA image

However, although the quality of the exported graph ( `xs2png()` ) is quite good, the quality of the imported graph with `imread()` is rather bad.

 ![grafik](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/1644e6dcc7a750cd184d473cdb04de7d1b3eeabe.jpeg)

The image (background + graph) could also be generated in Scilab itself using `Matplot()`.  
Just `Matplot()` the background and afterwards `Matplot()` the graph-image.

I consider this approach more as a practice in the way of “What is in general possible?” rather than a solution.

The approach itself is maybe more useful, if the content of a figure could be stored as a matrix. I mean: `xs2png()` stores the figure content as a image…something like `xs2three-channel-matrix()` should be possible.

Note: I used Scilab 6.1.1 and IPCV 4.1.2

Best Regards,  
Philipp

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [February 21, 2025, 7:07am UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/9 "2025-02-21T07:07:38Z")

</div>

> [@philipp](#):
>
> the quality of the imported graph with `imread()` is rather bad

This is just a question of display method. Matplot is used for this and doesn’t do any interpolation when scaling the image so the visual quality may look bad although it may look fine when displayed with system tools.

S.

---

<div class="post-metadata">

**Author:** ![philipp](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/philipp/32/53_2.png) [@philipp](https://scilab.discourse.group/u/philipp)\
**Post date:** [February 21, 2025, 11:32am UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/10 "2025-02-21T11:32:35Z")

</div>

Just another note:

`xs2bmp()` stores a 24 bit image, hence the result is a RGB image.

`xs2png()` stores a 32-bit image…hence the result is a RGBA image.

I guess however, that the “alpha” part is ignored or set to a value equal to “no opacity”.

I could imagine that it is possible to build a new function`xs2pngWithAlpha()` that is

- based on `xs2png()`
- takes a user input as definition for transparent color
- searches the figure content for this color
- sets the alpha channel at these pixel locations to “transparent”
- saves the result as a png file

I mean, at some point `xs2png()`must know the RGB values. So it should be possible to compare these against a user defined pixel value.

If so, Scilab would have a native function to generate transparent graphs.

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [February 21, 2025, 11:47am UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/11 "2025-02-21T11:47:58Z")

</div>

Hello Philipp,

Feel free to look at the xs2png sources to see what can be done.

S.

---

<div class="post-metadata">

**Author:** ![philipp](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/philipp/32/53_2.png) [@philipp](https://scilab.discourse.group/u/philipp)\
**Post date:** [February 21, 2025, 12:51pm UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/12 "2025-02-21T12:51:59Z")

</div>

Hello Stéphane,

I do remember your comment on the subject here…

> [@Opacity adjustment and export of multi-page pdfs not possible?](https://scilab.discourse.group/t/opacity-adjustment-and-export-of-multi-page-pdfs-not-possible/480):
>
> (using 6.1.1 on Windows 10) Hello, I looked into the issues of adjusting opacity in 2D plots and exporting multiple figures to one multi-page PDF-file quite extensively and at this point I am pretty sure, these features are simply not implemented in Scilab. Is my Assumption right or did I miss some functionalities? Thanks for your comments, Yann

> I am sorry but adding opacity in the general Scilab graphic model is a HUGE work beause it would necessitate to revamp the whole renderer module and it cannot be something else than a long term milestone. However, if you can afford to hire a Java/C++/OpenGL specialist we would be glad to help him to dive into Scilab project!

So, although it will most likely exceed my programming skills … out of interest I’d like to have a look.

Just: Can you give a hint where to look?

BR  
Philipp

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [February 21, 2025, 2:00pm UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/13 "2025-02-21T14:00:16Z")

</div>

> [@philipp](#):
>
> Just: Can you give a hint where to look?

> **[scilab/modules/graphic\_export · minor · scilab / scilab · GitLab](https://gitlab.com/scilab/scilab/-/tree/minor/scilab/modules/graphic_export)**
>
> Scilab is free and open source software for numerical computation providing a powerful computing environment for engineering and scientific applications.

---

<div class="post-metadata">

**Author:** ![philipp](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/philipp/32/53_2.png) [@philipp](https://scilab.discourse.group/u/philipp)\
**Post date:** [February 24, 2025, 7:58am UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/14 "2025-02-24T07:58:47Z")

</div>

Hi,

I put together some code for creating a transparent image from a figure.

Before posting the function `gui2rgba` , I’d like to ask if it is OK to put the code here. This is because it heavily relies on `gui2bitmap`.

Best Regards,  
Philipp

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [February 24, 2025, 8:39am UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/15 "2025-02-24T08:39:09Z")

</div>

Hello,

You should contact the author of gui2btimap and ask him to add your function in the toolbox.

S.

---

<div class="post-metadata">

**Author:** ![QwillDune](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/qwilldune/32/152_2.png) [@QwillDune](https://scilab.discourse.group/u/QwillDune)\
**Post date:** [February 25, 2025, 12:57am UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/16 "2025-02-25T00:57:06Z")

</div>

Hello [heinznabielek](https://scilab.discourse.group/u/heinznabielek)

Is this something like that you want to do ?

 ![Out_Map](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/9cde5e2a3b2939a7758465c2a313c6ac6106c7d2.png)

The Map is a JPG file  
On top I plotted random dots  
And save it PNG and JPG  
Using SCICV toolbox  
[Plot\_on\_Map.sci](https://scilab.discourse.group/uploads/short-url/dzUPEHClsptpvMCeW0E2JnykRSU.sci) (809 Bytes)

 ![In_Map](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/a12549470f5de33d7d08899c4c22ec9314c9a7b4.jpeg)

BR  
François

---

<div class="post-metadata">

**Author:** ![heinznabielek](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@heinznabielek](https://scilab.discourse.group/u/heinznabielek)\
**Post date:** [February 25, 2025, 2:01am UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/17 "2025-02-25T02:01:44Z")

</div>

Beautiful. Yes great. But how exactly do I arrange correct longitude and latitude? Heinz

---

<div class="post-metadata">

**Author:** ![philipp](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/philipp/32/53_2.png) [@philipp](https://scilab.discourse.group/u/philipp)\
**Post date:** [February 25, 2025, 8:29am UTC](https://scilab.discourse.group/t/transparent-scilab-graph/822/18 "2025-02-25T08:29:55Z")

</div>

If your map grid coordinates are horizontal/vertically like in the example below, it is rather easy…you just need to boundary coordinates of your map [left, right, top, bottom] .

E.g. you need to search for the most west, east, north, south coordinates that are represented by the map.

 ![grafik](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/f38e533dd194ab95202cd1962fdb8920683a225d.jpeg)

Plot the map via `Matplot()` or `imshow()`  
If you use `Matplot()` make sure to set axes margins to [0 0 0 0];  
Than use `newaxes()` to have an new axes entity for the lat/long coordinates of your data.  
Adjust the `data_bounds` of the axis to the map boundaries.  
That should do the trick.

Best Regards,  
Philipp
