I am trying to learn how to animate things in react native. I have a few things working but now I want to use the translateX and scaleX etc.
I have this working which simply spins the image :
const spin = spinValue.interpolate({
inputRange: [0, 1],
outputRange: ['0deg', '360deg']
})
and now I would like to use something like this to make the image bigger but I can not get it to work? :
transform: [
{
translateX: this.animatedValue.interpolate({
inputRange: [0, 1],
outputRange: [0, 120]
})
I have tried but it doesnt work?
const spin = translateX: animatedValue.spinValue.interpolate({
This is not all of it just snippets of what I am trying. Am I doing it totally wrong or is it something else?
Any help would be appreciated.
Related
Does anyone know if it is possible to specify a mapping that varies the size of markers in a Plotly scattermapbox visualization as one varies the zoom level? I'd like to layer a scattermapbox visualization over a densitymapbox visualization and have the scatter plot be invisible at larger scales but come into view as one zooms in.
Thanks!
you can specify minzoom on layers
below example shows a density mapbox that are replaced by red markers after zooming in past zoom 4
this clearly works where markers and density items are the same. If different, best that you update question with sample data
import plotly.express as px
import pandas as pd
import geopandas as gpd
import shapely.geometry
import json
df = pd.DataFrame(
data=(
[
[32.4087249155, -100.9509696428, "2013-01-01", 1],
[31.5201976084, -102.1030942593, "2013-01-01", 1],
[31.434573418, -102.0592907601, "2013-01-01", 1],
[31.2635930582, -101.95341361, "2013-01-01", 1],
[31.4287233847, -102.0253840388, "2013-01-01", 1],
[31.4872286706, -101.5455598032, "2021-01-01", 1],
[31.5439162579, -101.4833865708, "2021-01-01", 1],
[31.5439362581, -101.4833065695, "2021-01-01", 1],
[31.7980713977, -102.0937650441, "2021-01-01", 1],
[32.02050082, -103.31736372, "2021-01-01", 1],
]
),
columns=["Latitude", "Longitude", "Date", "Count"],
)
fig = px.density_mapbox(
df,
lat="Latitude",
lon="Longitude",
z="Count",
radius=10,
zoom=3,
)
# fig = go.Figure(go.Scattermapbox())
fig.update_layout(
mapbox_layers=[
{
# "below": "traces",
"circle": {"radius": 10},
"color":"red",
"minzoom": 4,
"source": gpd.GeoSeries(
df.loc[:, ["Longitude", "Latitude"]].apply(
shapely.geometry.Point, axis=1
)
).__geo_interface__,
},
],
mapbox_style="carto-positron",
)
I am trying to do some simple visualizations using seaborn.
def show_figures():
sns.barplot(ax=axes[0, 0], x=df['Genre'], y=df['NA_Sales'])
sns.barplot(ax=axes[0, 1], x=df['Genre'], y=df['EU_Sales'])
sns.barplot(ax=axes[1, 0], x=df['Genre'], y=df['JP_Sales'])
sns.barplot(ax=axes[1, 1], x=df['Genre'], y=df['Other_Sales'])
show_figures()
plt.xticks(rotation=70)
plt.show()
I wanted to rotate the xticks of axes[1, 0] too, but I got this:
How can we rotate the xticks of all subplots ?
Thank you!
Is it possible to display an inverted fill in an area chart?
I am using the Vue-apex-charts library. I'm trying to create a chart that looks like the following where the red region is not stacked up from the baseline, but descends from the top of the chart.
fill: {
type: "gradient",
gradient: {
shadeIntensity: 0.9,
opacityFrom: 0.7,
opacityTo: 0.5,
stops: [0, 80, 100]
}
},
I want to draw very simple graph with 4 nodes and 3 edges:
from numpy import array, vstack
from mayavi import mlab
mlab.figure(1, bgcolor=(1, 0.9, 1))
mlab.clf()
x = array([0, 3, 2, 3])
y = array([0, 4, 5, 1])
z = array([0, 0, 1, 1])
color = array([0.1, 0.3, 0.5, 0.7])
pts = mlab.points3d(x, y, z,
color,
scale_factor=1,
scale_mode='none',
colormap='Blues',
resolution=20)
edges = vstack([[0, 1], [0, 2], [0, 3]])
pts.mlab_source.dataset.lines = edges
tube = mlab.pipeline.tube(pts, tube_radius=0.1, tube_sides=7)
mlab.pipeline.surface(tube, color=(0.8, 0.8, 0.8))
mlab.show()
It returns that:
Why edges are missing?
There is a bug in Mayavi about this. It is related to unsynchronized changes with VTK and are thus a bit hard to pinpoint. There is a discussion on Mayavi's GitHub https://github.com/enthought/mayavi/issues/388
The bug also shows up with the protein.py example that comes up with Mayavi and it is fixed there by adding
pts.mlab_source.update()
after setting the lines. It is fixed online for the example at https://github.com/enthought/mayavi/commit/afb17fceafe787c8260ca7a37fbb3b8c2fbfd36c
Using the fix did not work for me though but you might try.
I use the fantastic Seaborn library for some summary stats in IPython Notebook. I recently switched over to a dark color theme for my notebooks and am trying to figure out the best seeings for Seaborn with a dark background. I am using the darkgrid style but the legends are still being printed in black which makes them impossible to read. Here is an example:
What is the best way to fix my styles of use of Seaborn to make the legends appear on white?
UPDATE:
I just noticed that the same problem exists with my Matplotlib graphs.. so my question is more general. What styles do you use to allow for white on dark plots so the legends are readable?
You can customize the seaborn style, and it tries to make it relatively easy to do so.
If you want to see each of the parameters that is considered part of the "style" definition, just call sns.axes_style() with no arguments, and it will return the current settings. As of 0.3.1 and for the default style ("darkgrid"), that looks like this:
{'axes.axisbelow': True,
'axes.edgecolor': 'white',
'axes.facecolor': '#EAEAF2',
'axes.grid': True,
'axes.labelcolor': '.15',
'axes.linewidth': 0,
'font.family': 'Arial',
'grid.color': 'white',
'grid.linestyle': '-',
'image.cmap': 'Greys',
'legend.frameon': False,
'legend.numpoints': 1,
'legend.scatterpoints': 1,
'lines.solid_capstyle': 'round',
'pdf.fonttype': 42,
'text.color': '.15',
'xtick.color': '.15',
'xtick.direction': 'out',
'xtick.major.size': 0,
'xtick.minor.size': 0,
'ytick.color': '.15',
'ytick.direction': 'out',
'ytick.major.size': 0,
'ytick.minor.size': 0}
A good heuristic is that you probably only need the parameters with "color" in the name, so you can filter it:
{k: v for k, v in sns.axes_style().items() if "color" in k}
returns
{'axes.edgecolor': 'white',
'axes.facecolor': '#EAEAF2',
'axes.labelcolor': '.15',
'grid.color': 'white',
'text.color': '.15',
'xtick.color': '.15',
'ytick.color': '.15'}
You can then pass a custom dictionary with values for these parameters into sns.set_style():
custom_style = {'axes.labelcolor': 'white',
'xtick.color': 'white',
'ytick.color': 'white'}
sns.set_style("darkgrid", rc=custom_style)
Why not simply
plt.style.use("dark_background")
sns.set_style("darkgrid")
Will make the background white so that you can see the text.
I find that adding this
plt.figure(facecolor='w')
each time I plot takes care of the axes background.