1

Here is a Python code that creates a plot with 6 defined colors and saves it in a PNG file:

import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np

# Define a colormap of 6 colors
palette = ['#0d0887', '#6a00a8', '#b12a90', '#e16462', '#fca636', '#f0f921']
my_cmap = mpl.colors.ListedColormap(palette)

# Plot the 6 colors
a = np.arange(3*2).reshape(3,2)
plt.pcolormesh(a, cmap=my_cmap)

# Print hex colors
for i in range(my_cmap.N):
    rgba = my_cmap(i)
    # rgb2hex accepts rgb or rgba"
    print(f"'{mpl.colors.rgb2hex(rgba)}', ", end='')

# Save figure
plt.savefig('test.png')

The plot created inside the Jupyter Notebook contains the correct colors, i.e. a color picker tool provides the same hex color values that are defined in the script.

colors in Jupyter Notebook

correct picked colors

However, when opening the saved PNG file with GNOME Image Viewer, the colors values obtained with the picker tool are different:

colors in GNOME Image Viewer

wrong picked colors

Colors are correct when opening the file with Shotwell.

System information:

  • Ubuntu 23.10
  • GNOME Shell 45.2
4
  • I used your code to see if I can reproduce your issue (BTW you need to have import matplotlib as mpl) but I couldn't. The colors picked are the same as the ones produce by your code both when picked from Loupe (current Image Viewer) and EoG (previous Image Viewer) on GNOME 46. Since your issue is about the Image Viewer (EoG) on Ubuntu 23.10, which is not supported anymore because it reached its EoL in July 11, that makes your question off-topic and you are advised to upgrade to a supported version (24.04). Commented Jul 19 at 10:14
  • If you don't want to upgrade (which is not recommended), you may continue using Shotwell or another image viewer that shows the correct colors. If you upgrade to 24.04 and you still have this issue, just edit your question to let us know. I'm following your question and I will get notified that you edited it so that it can be reopened if it gets closed as off-topic for being about an EoL version (it most likely will). Thanks for your understanding! Commented Jul 19 at 10:19
  • Have a look at this thread as well, in case any suggestion works for you: Image colors are wrong in 'eog' Commented Jul 19 at 10:21
  • @BeastOfCaerbannog Thanks! I plan to upgrade asa 24.04.1 is released.
    – TVG
    Commented Jul 19 at 13:40

0

Browse other questions tagged .