How to plot a single column using Seaborn? - seaborn

suppose i have a dataset like this
a=np.array([1,2,3,4,5,6,7,8,9])
b=np.array([1,2,3,4,4,4,4,4,4])
I want to compare the two dataset and see the difference between them, something like this
I am not able to find any method in seaborn with which i can achieve this, methods like lineplot or scatterplot requires both x and y axis, can anyone help on this

i just found out the answer
import seaborn as sns
import numpy as np
sns.lineplot(data=_a)
previously, i was using like this which was causing error
sns.lineplot(x=_a)
sns.lineplot(_a)

Related

How to add details in seaborn pairplot

I want to add pairwise correlation onto the pairplot but couldn't find a parameter to add the annotation, only a complicated method below. However, using this user-defined function, the r annotation seems overlapping. Not sure what caused this. How to fix this? Also is there a parameter to normalize input variables in pairplot? Thank you.

How can I add basemaps to a seaborn jointplot?

Can someone guide me on how best to add a background map to two seaborn jointplots I created?
To give context, I am currently analyzing a dataset from Austin Police Dept's Crime Reports database. What I am attempting to do is visualize the density of murders and capital murders in Austin, TX. The dataset extends from the beginning of 2003 to the present.
The notebook can be located at: https://github.com/rgrantham82/Hate_Crimes_Analysis/blob/master/Austin%20Crimes%20Report%20Analysis.ipynb
So far, I visualized both data frames using the seaborn jointplot method, using latitude and longitude.
I BELIEVE this is a good method to plot the density of murders judging by the dataset but if someone has a better idea, I am open to instruction on that as well.
So, if it is even possible, how do I add a basemap to both plots?
So far, I attempted the contextily method and the geopandas method. Admittedly, this is my first attempt (outside of DataCamp class) using either method. As of to date, I am unsuccessful with both.
The contextily addbasemap() method did not produce a map (I guess it does not have one for the Austin area?). And also with the geopandas method I could not get it to work in producing a viable basemap either. I seem to be simply swamped by it.
Murders Plot
Capital Murders Plot

H2O Frame constructed from multiple parts

My training frame is rather large, so I'd like to import them in a way similar to S3's multipart upload. Is the correct way to do this to manually import_file for all the parts, then call rbind on all of these parts? Or is there a more correct way or built-in of doing this?
the function h2o.import_file can handle import from multiple files on it's own. This works both in Python and R.
Python:
data = h2o.import_file(["/home/some/path/to/airliens/airline1.csv",
"/home/some/path/to/airliens/airline2.csv"])
R:
data = h2o.importFile(c("/home/some/path/to/airliens/airline1.csv",
"/home/some/path/to/airliens/airline2.csv"))

FacetGrid Seaborn taking long time to plot

I have a major concern regarding why in the world the above code:
sns.FacetGrid(iris , row='petal_length' , col='petal_width');
This statement is taking around 10 minutes to execute and I get a single large extremely large white grid.
Why is this happening please help me removing this behavior of the code.
If you are using Jupyter notebook you need to put "%matplotlib inline" in your code after importing matplotlib.pyplot and seaborn library. It allows jupyter notebook to see the plots and diagram that you are trying to create.
I also got stuck in my NLP project then I remembered I forgot this statement in my code.
Hope it helps.

geopandas projection problems

I'm handling shp files now and I encountered problems with the projections.
Let me give you my code below.
import pandas as pd
import geopandas as gpd
from geopandas import GeoSeries, GeoDataFrame
import os
Aelly = gpd.read_file(r'C:\Users\Hyun Mo\Downloads\조인 (1)\after_join.shp', encoding = 'utf-8')
base_map = gpd.read_file(r'C:\Users\Hyun Mo\Downloads\11000 (3)\TL_SCCO_SIG.shp', encoding = 'ANSI')
Aelly_to_crs = Aelly.to_crs(base_map.crs)
Aelly_to_crs.plot(ax=base_map.plot())
And here is my data construction
print(base_map.head())
print(Aelly.head())
When I executed print(base_map.crs), print(Aelly_to_crs.crs), I got the results like below.
Aelly_to_crs.plot(ax=base_map.plot())
The above picture is the result of executing Aelly.plot(ax=base_map.plot())
And you can see that the two pictures don't match each other.
How can I solve this problems??
-----------edit
My desired output is below picture.
Here are my data links:
http://blog.naver.com/khm2963/220929301892
below pictures are procedure for downloading my flie
From the data that you have printed it looks like everything is working as it should! The coordinates between the shapefiles are very different, but crs is the same, so the plot totally makes sense.
GeoPandas isn't able to tell you whether the data and number make sense in a real world. You gave it two shapefiles with well defined projection (EPSG: 32652) and with hardcoded coordinates and GeoPandas is happy with that.
If you know that in reality both shapefiles represent the same area, then you are the one that has to realize that datasource is somehow corrupt. I think that one of the shapefiles accidentally got a different crs definition as a metadata (imagine it as a wrong text encoding, for instance).
The easiest way to figure that out and correct it is by using ArcGIS or QGIS software, where you can play with different projections in order to figure out, what the correct projection was. Then you can save the shapefile with new projection metadata and the rest will work out of the box.

Resources