How to center a dataframe in streamlit new version - python

I had no problem with the alignment in the old version but when I upgraded to the new version I saw this happen. I tried the following 3 different approach below the dataframe but none of them fixes the problem. Is there any way to work around it?
#Sets df size with width 1000 and height 300, but width has a limited range
st.dataframe(df, 1000, 300)
st.dataframe(df, use_container_width=True)
st.write(df, use_container_width=True)

I ask this question for a while now but yet didn't get any response until I figured a way to handle my problem.
I used streamlit AgGrid Component to fix my problem. AgGrid() by default will center the dataframe, it also has other awesome features of handling data frames much better than st.dataframe() and it is pretty simple and clean. I could even choose to color the data frame to my liking which I found pretty cool and interactive.
In case you face similar problem and want to take this approach I will recommend you visit streamlit AgGrid Component to know the inside of the component and how it is implimented.
from st_aggrid import AgGrid
AgGrid(df)
OUTPUT:

Related

Changing aspect on Jupyter Notebook

So I've just start playing with dataframes and the first problem I encounter was this.
In the tutorial (this is not a single example) after doing the df.head command, the data frame showed like in the left side of the picture. On the right side is my result doing the same outputs, the only difference is the tutorial is doing on windows computer, and I am doing on a Mac.
Can somebody guide me how to make the aspect of dataframe to be more understandable and easier to work with?
L.E:Actually I can't post the picture, but is there any command that I can use to put the data frame in a table, to be more readable.

Hosting interactive matplotlib plots online

I've built a simple program using matplotlib widgets to label a series of images for a classification task (see image below). My script adds the label and filename to a pandas dataframe depending on the button chosen in the window and moves on to the next image. When finished saves the whole dataframe to a csv.
Example Labelling Interface
I chose to build it rather than use something already out there as most programs seemed too complicated for the type of problem I have and I was hoping for a quick labelling solution - here it's just a simple click of a button and it's on to the next image.
My initial plan was to have a labelling program which I can host somewhere (something like AWS or Azure) in an app where others could simply go to a link and help with classifying some images, however I've found it hard to find anything on this.
I'm looking for general advice on if
a) hosting mpl interactive plots online is possible (if so any information would be greatly appreciated)
b) there's a simpler way to package this together to distribute to others without hosting online
c) there's a much better solution which I've somehow missed
Thanks in advance for any help!

How to create a very specific data diagram using Python

I would like to make a diagram in Python similar to the one shown below. From what I've seen so far, there is no a library that I could use directly. Can you suggest me where to start from, for example, would it be worth to improvise by stacking horizontally multiple subplots. Is there maybe a better approach?
Thanks!
I believe the name you're looking for is Parallel Coordinates Plot.
I'm sure Plotly supports it and there are tutorials online for other libraries as well.
Let me know if this helps.
Edit: and judging by this image from Plotly's docs your example image comes from there.

Bokeh shows plot blurred on windows

I am using bokeh for plotting. With my current settings, bokeh shows some text and lines kind of blurred (anti-aliased?). This is not really noticeable on my monitor, but on some projectors, especially when doing screenshots and inserting them into presentations, it looks weird.
As requested, a minimum working example:
from bokeh.plotting import figure, show
p = figure(plot_width=1000, plot_height=600,
title="TestTitle", x_axis_label = "Length [cm]", y_axis_label="Height [m]")
p.xaxis.axis_label_text_font_style = "normal"
p.xaxis.axis_label_text_font_size = "12pt"
show(p)
I am using Windows 7 and tried this in the current versions of Chrome and IE. Python 3.6, bokeh version 0.13.0. The first image is taken from the example, the second is taken from my real code:
I tried different figure sizes, but the problem persists - maybe I am trying the wrong ones? Anything I can do about this, except simply trying different sizes until something "works"? Setting px instead of pts seems to make it worse...
Regarding the text, it is rendered on to a raster HTML canvas, and the details of how this is done are entirely dependent on the browser canvas implementation. (FWIW things look better on any browser on OSX than the above image.) There's not anything we can to change how a specific browser renders text, and not much I can suggest except to make much bigger canvas sizes if you need to show something extremely magnified.
Regarding the aliasing of the axes and tick marks, I can't reproduce anything like that on any OSX browser (Safari, FF, or Chrome). It definitely appears to be a Windows-specific issue. It's possible there are issues that could be addressed, e.g a different HiDPI setting, or half-pixel offsets, but it would take investigation to try and determine what can be done. A Github issue with details would be appropriate, but I can't speculate when it might be addressed (we are under-resourced and no core contributors are regular windows users).

How to save matplotlib figure in max windows form instead of default size?

Anyone know how should i work around with that?
I know there is save button which I could do it manually but I am plotting 100+ graph so I hope there will be a way to doing it automatically?
I was using 'TkAgg' backend and I look up for any possible solution around. By using the following at the end of my plot function.
manager = plt.get_current_fig_manager()
manager.resize(*manager.window.maxsize())
plt.savefig(r'C:\Users\310293649\Desktop\PlotFigure\TESTING.png')
plt.show()
EDIT: Tried with this as well but still I was able to plt.show() the figure in the desired way I prefer which is full windows size. But it still automatically save all of my figure in minimize default form.
wm = plt.get_current_fig_manager()
wm.window.state('zoomed')
plt.savefig(r'C:\Users\310293649\Desktop\PlotFigure\TESTING.png')
plt.show()
Below is what I got after plt.show() from above command,
plt.savefig result that I got:
As you can see The code managed to show the plot in max windows size but it still automatically saved the plot with default size So I was wondering if it is possible or is there any solution to save the matplotlib figure in max windows size automatically? OR there is no way I can do that?
Below images is the figure when I done it manually with the save figure button in matplotlib:
EDIT: How to make pylab.savefig() save image for 'maximized' window instead of default size - Most of the answer here refer to showing the figure in full windows form but when it come to saving the max windows automatically(it still save it in the normal size)...you can see the author of the ques have raised up the issue in the comment section of all of the answer but was not answered.
Apparently, this is a bug introduced in Matplotlib 2.0 (January '17).
See here and here.
There seems to be a fairly simple code change to fix this here, but you'll have to apply it yourself since it's not included in any released version yet (it's planned for 2.1.1 2.2).

Categories

Resources