Python plotly: bars hardly visible from background - python

I am trying to build a default bar chart in plotly using Plotly express (imported as px). However, the default (and manually chosen) colors hardly differ from the background. The legend will show appropriate colors.
edit: The very basic call
px.bar(credit_cards, x='Marital_Status')
will give similar if not less visible results.
An image of the Notebook
is attached.
Thanks in advance!
Edit/kind of solution: using px.histogram instead of px.bar displays bright colors. I would still be interested in what is wrong with bar, though.

Related

How to set a horizontal scroll bar and zoom bar for a Bar Chart in PyQt5 using PyQtChart?

I would like to have a horizontal scroll bar and zoom bar for this QChartView containing a QBarSeries from PyQtChart library because the bars displayed inside the QChartView get compressed as the number of data to visualize increases. Thus, I would like to have a fixed size for each bar plot for them not to be compressed and can be viewed along with horizontal scroll bar and zoom bar. This image shows the problem of having too much data to visualize in my case. May I ask if there is anything I can do to achieve my goal? Any response would be highly appreciated. Thank you very much!
I tried searching for similar problems but unfortunately, I did not find one. Although I was able to find similar problems, they were written using C++ which I am not familiar of.

Image background in bar charts using bokeh (python)

I have a basic bar chart with the x-axis having categorical values of countries. I want to give each bar, an image background of the country's flag, to make the chart more appealing also to eliminate the x-axis labels. I am currently using bokeh for my charts and I dont think it is possible via this. Any ideas for the same, maybe some other python libraries which might do the trick?
Thanks

Black background behind a figure's labels and ticks, only after saving figure but not in Python Interactive view (VS Code with Jupyter functionality)?

I have a strange problem where if I save a figure, its labels and ticks will have a black background, see this example:
plt.savefig("asdsadsad.png")
I'm not even including any code here because this happens on the simplest plotting, even with code that I made earlier with a different computer that never had this problem. I'm using VS Code with Jupyter functionality and the figures look normal in the Python Interactive view, but have the black border when saved.
Any ideas what could cause this strange problem?
plt.savefig will not use the same settings that you plotted with. That's why the saved image might look different from what you have plotted in Python. To define the background color of your figure, you need to define the facecolor parameter when you call savefig.
plt.savefig('asdsadsad.png', facecolor='w')
Your default facecolor may be set to black in your rcParams
I think I got the same issue, besides having facecolor and edgecolor set to white ('w'). For some strange reason the problems occured only with PNG image format and shifting to JPG solved everything.

How to display a binary state (ON/OFF) in Matplotlib?

I have built a GUI with matplotlib and it contains several plots of values versus time. Now I need a special plot which just shows if a value is on or off (binary state).
Kinda like a control lamp on an analog control panel. I have 5 of those on/off values and I dont know how to do it the best way.
The "lamps" must be updateable because I stream the data from serial and analyze it in real time in my GUI.
I attached a picture where you see my current GUI. In the bottom right corner is now a bar chart, I tried to visualize the ON/OFF state with a bar, but it didn't work well and I wasn't able to animate it.
So yeah, how could I display 5 values with each an ON/OFF state in that area?
Instead of passing via bar charts I would directly plot a number of rectangles and then dynamically change their color.
You can find the documentation for rectangular patches here: http://matplotlib.org/api/patches_api.html#matplotlib.patches.Rectangle
If you need some pointers on how to animate such a patch have a look here:
https://nickcharlton.net/posts/drawing-animating-shapes-matplotlib.html

certain seaborn plot colors not displaying on projector

I often have to present my data analyses in meetings where we either use a projector or a large TV monitor, an example plot might look like this (generated with seaborn):
I've noticed that often times, certain colors will not show very well (if at all) on these displays, whereas it shows just find on my computer monitor. For example, in this example, the gray background will not show at all.
Is there another set of colors I can use that are "safe" to use with projectors and TV monitors?
I guess the problem is caused by bad contrasts or dynamic ranges of cheap projectors. By default, seaborn uses somewhat muted low-contrast color schemes because these are nicer to the eye.
You can use the function seaborn.set_palette to change the colors used.
The seaborn documentation has a nice page about color palettes that explains how to create different color schemes.
For example, seaborn.set_palette(seaborn.hls_palette(8, l=.3, s=.8)) gives 8 rather dark colors (lightness 0.3) that I believe will work well with projectors:
P.S. There is also a dark variant of the default six-color palette in seaborn. I have not tried, but I think it can be set by seaborn.set_palette('dark')
P.P.S. These color palettes have no effect on the background, though. This answer may help out there.

Categories

Resources