colorcet | useful perceptually uniform colormaps | Data Visualization library
kandi X-RAY | colorcet Summary
kandi X-RAY | colorcet Summary
Colorcet is a collection of perceptually uniform colormaps for use with Python plotting programs like bokeh, matplotlib, holoviews, and datashader based on the set of perceptually uniform colormaps created by Peter Kovesi at the Center for Exploration Targeting.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Get the version of setup cf file
- Create a version file
- Get git setup version
- Extract tag from setup py directory
- Create a sinewamp image
- Wrapper around swatches
- Get a list of aliases
- Plot an image
- Return all original names in palette
- Return the setup version
- Print a dictionary
- Merge old aliases
- Find conflicts between two dictionaries
- Plot multiple images
- Create an image plot
- Return a hover button
- Pre - release
- Fetch the repo
- Merges the old cetnames
- Create a matplotlib colormap
- Create a colormap
colorcet Key Features
colorcet Examples and Code Snippets
df = get_data()
@pn.depends(years)
def get_plot(years):
if years:
df1 = df[years]
mplot = get_mplot(df1, years)
return mplot
def button3_reset():
nonlocal step
step = 0
data = []
fig.title.text = 'Streaming Line Plot - Step '+str(step)
for i in range(len(strategies)):
init_data = dict(step=[step],
age_band_group = df.groupby(['age_band']
).agg(count=('age', np.size)
).fillna(0)
age_band_group.hvplot.bar(color='teal')
def bivar_cat(x='sex', y='age_band'):
fig, ax = plt.subplots(figsize=(15,10))
mosaic(df, [x,y], ax=ax)
plt.close()
return fig
app_df_cat = pn.interact(
bivar_cat,
x=cat_atts,
y=cat_atts,
)
app_df_cat
matplotlib.colors.SymLogNorm(linthresh, linscale=1.0, vmin=None, vmax=None, clip=False)
ax.contourf(xx, yy, trends, cbarticks, cmap=cmap, levels=levels_def,
norm=mpcol.SymLogNorm(linthresh=0.03, lin
from random import random
from bokeh.layouts import column
from bokeh.models import Button, ColorBar, BasicTicker
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure, curdoc
from colorcet import CET_L18 as palette
f
Community Discussions
Trending Discussions on colorcet
QUESTION
data source: https://catalog.data.gov/dataset/nyc-transit-subway-entrance-and-exit-data
I tried looking for a similar problem but I can't find an answer and the error does not help much. I'm kinda frustrated at this point. Thanks for the help. I'm calculating the closest distance from a point.
...ANSWER
Answered 2021-Oct-11 at 14:21geopandas 0.10.1
- have noted that your data is on kaggle, so start by sourcing it
- there really is only one issue
shapely.geometry.MultiPoint()
constructor does not work with a filtered series. Pass it a numpy array instead and it works. - full code below, have randomly selected a point to serve as
gpdPoint
QUESTION
I am trying to make plots with datashader. the data itself is a time series of points in polar coordiantes. i managed to transform them to cartesian coordianted(to have equal spaced pixles) and i can plot them with datashader.
the point where i am stuck is that if i just plot them with line()
instead of points()
it just connects the whole dataframe as a single line. i would like to plot the data of the dataframe group per group(the groups are the names in list_of_names
) onto the canvas as lines.
data can be found here
i get this kind of image with datashader
This is a zoomed in view of the plot generated with points()
instead of line()
the goal is to produce the same plot but with connected lines instead of points
ANSWER
Answered 2021-Sep-29 at 16:10To do this, you have a couple options. One is inserting NaN rows as a breakpoint into your dataframe when using cvs.line
. You need DataShader to "pick up the pen" as it were, by inserting a row of NaNs after each group. It's not the slickest, but that's a current recommended solution.
Really simple, hacky example:
QUESTION
I am working on a little widget with holoviews
and panel
- it consists of reading a pandas.dataFrame
and display a curve for each column. The interaction I need is to be able to add/remove columns from the plot.
In my real use case, there are too many columns so I can’t take advantage of the interactive legend already provided by bokeh+holoviews
.
I made a little example that ‘’’ kind of works ‘’’ but I am probably doing it wrong, as I am reloading the data for the plot every time there is an interaction with the panel.widgets.MultiChoice
(which is obviously wrong)
ANSWER
Answered 2021-Mar-03 at 11:24I think you just need to do your data loading first and not overwrite the dataframe, like:
QUESTION
When plotting a set of data in datashader it will, if the X-axis has discrete numbers and undersampling, leave gaps between the colums where the background can be seen.
I have been trying to fix this by trying to set a larger point size or by using the dynspread transfer function. No luck - it could well be that I just don't know the correct way of applying these.
Here is sample code to reproduce what I mean:
...ANSWER
Answered 2021-Mar-03 at 02:34Datashader is working as designed in this case. When rendering points into a raster grid, it shows you the actual point data available, up to the limit of what the pixel grid can show. If there are multiple datapoints in a pixel, their counts or values are aggregated. If there is no data in some pixels, no data is shown.
It sounds like you want a different sort of plot than a datashaded pixel heatmap. Maybe:
- If your data represent regular samples from an underlying raster or quadmesh grid, use a datashaded hv.Image or hv.Quadmesh plot (or call canvas.raster or canvas.quadmesh directly), not an hv.Points or canvas.points plot
- If your data represent arbitrarily located samples from an underlying continuous distribution, you can use a datashaded hv.TriMesh or canvas.trimesh plot to fill in between dots after you compute a Delaunay or other type of triangulation so that it defines a surface.
- If your data represent arbitrarily located samples from a non-continuous distribution but you still want to approximate it with a continuous function, you can use a (non-datashaded) hv.Bivariate plot, which computes a smooth kernel density estimate that effectively "connects the dots" as you describe but also smooths out local density differences.
None of these options do precisely what you're asking here, but I think the TriMesh will behave the most like you suggest, while still behaving similarly for the zoomed-out case.
QUESTION
I want to make use of a promising NN I found at towardsdatascience for my case study.
The data shapes I have are:
...ANSWER
Answered 2020-Aug-17 at 18:14I cannot reproduce your error, check if the following code works for you:
QUESTION
For a scatterplot with datashader I want to incorporate the notion of time into the plot. Potentially by using color.
Currently,
...ANSWER
Answered 2020-Apr-19 at 17:45Datashader can colorize using any categorical column. Here, you have only four distinct dates, which already works as a categorical, but if you have a lot of dates, you'll first want to bin them into a suitable set of date ranges (e.g. less than 256 total values, if you use a 256-color colormap).
Either way, once you have a categorical column c
, pass agg=ds.count_cat('c')
to your .points()
call, and you should get a plot colorized by date.
See the 'pickup_hour' plot in https://examples.pyviz.org/nyc_taxi/ for examples.
QUESTION
I am currently trying to project a dataset (Berlin public transport spots) on to map tiles with the help of datashader and bokeh. To certain extents it worked nicely, while three problems remain:
- when zooming into the data, the pixels remain rather large and are not rearranged - how to do this?
- how to get the projected data semi-transparent to still see the map below?
- the "save"-function of the bokeh toolbar disappeared, as the map tiles were merged. How to get it back?
Thanks for any input!
the (far from perfect) code written:
...ANSWER
Answered 2020-Mar-01 at 13:50"when zooming into the data, the pixels remain rather large and are not rearranged - how to do this?"
Datashader is a Python program that produces an array of rasterized values when given a data structure. Here, it is rendering your data as requested, and you are then saving the output of it to an HTML file using
hv.save
. Once you do that you will have a figure that will never update. You'll zoom in on the HTML page, causing the browser's JavaScript code to request an update from Python, but Python is not running and cannot respond to the request for an updated figure. If you want a zoomable image exported to HTML, you'll need to either specify a much higher initial resolution with something likedatashade(..., dynamic=False, height=4000, width=4000)
(which will give a big file size and may not look great initially, but will allow some degree of zooming), or else generate a whole set of data tiles at lots of various resolutions (supported by Datashader but not yet well documented), or else (for full power) use Bokeh server to provide a Python process to accompany the HTML/JavaScript code. I.e., either generate a bit more data initially, generate all combinations of data beforehand, or provide a server that can regenerate them on demand. Without one of those approaches, you should not expect to have any data available beyond the initial rendering.how to get the projected data semi-transparent to still see the map below?
bvg_stops.opts(alpha=0.5)
. You can also consider using Panel.pyviz.org to add some widgets for opacity for the map and the data to let you turn them on and off interactively; see examples.pyviz.org for examples.the "save"-function of the bokeh toolbar disappeared, as the map tiles were merged. How to get it back?
Unfortunately, this is a limitation caused by the browser's security model, and is not something Bokeh or any of the other tools here can override. The map tiles come from a separate server, and browsers disable exporting such "cross-origin" content to avoid certain security issues (Can't Save Bokeh Plot with Panel from PyViz Example).
QUESTION
import pandas as pd
import numpy as np
import random
import copy
import feather
import plotly.graph_objects as go
import plotly.express as px
import panel as pn
import holoviews as hv
import geoviews as gv
import geoviews.feature as gf
import cartopy
import cartopy.feature as cf
from geoviews import opts
from cartopy import crs as ccrs
import hvplot.pandas # noqa
import colorcet as cc
from colorcet.plotting import swatch
hv.extension("bokeh","plotly")
...ANSWER
Answered 2020-Jan-15 at 20:53The problem is caused by your variable age_band being categorical, having 0 counts for some of the categories and using it with the keyword by=['age_band]
.
You could try converting age_band to a string, but in this case creating a barplot is nicer I think:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install colorcet
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page