multicolored background, values offset from gridline
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You can use geom_rect together with geom_line too simulate this effect. If you really want lines instead of points you could add shape="|" in geom_point. p<-ggplot(hab,aes(x=score, y=metric))+theme_classic()+geom_rect(aes(xmin = 0 , xmax = 25) , ymin = -Inf , ymax = Inf ,fill = "#F15922") +
geom_rect(aes(xmin = 25 , xmax = 50) , ymin = -Inf , ymax = Inf ,fill = "#F7941E")+
geom_rect(aes(xmin = 50 , xmax = 75) , ymin = -Inf , ymax = Inf ,fill = "#00BAF2")+
geom_rect(aes(xmin = 75 , xmax = 100) , ymin = -Inf , ymax = Inf ,fill = "#00A975")+
geom_vline(xintercept=seq(0,100,by=25),colour="white",size=1.5)+
geom_hline(yintercept=c(seq(0,0.5,by=0.1),seq(1.5,15.5,by=1),seq(15.5,16,by=0.1)),colour="white",size=1.5)+
geom_point(colour="white", size=4) + geom_point(colour = "black",size=3)+
geom_text(aes(label = "Poor", x = 12.5, y = 16), vjust = 1.2,size=4)+
geom_text(aes(label = "Fair", x = 37.5, y = 16), vjust = 1.2,size=4)+
geom_text(aes(label = "Good", x = 62.5, y = 16), vjust = 1.2,size=4)+
geom_text(aes(label = "Excellent", x = 87.5, y = 16), vjust = 1.2,size=4)
p
|
Multicolored UISlider, is it possible?
Tag : ios , By : FarmerDave
Date : March 29 2020, 07:55 AM
I wish this help you You can do this without adding/managing your own subviews, but you will need custom images. You can use the setMinimumTrackImage:forState and setMaximumTrackImage:forState which are built in properties of the UISlider API. The minimum image will show from the minimum end of the slider to the thumb image, and the maximum image will show from the thumb image to the maximum end of the slider. So you could either make these the same, or different, depending on the effect you want to create. Customizing the slider's appearance Apple reference
|
Plot Multicolored line based on conditional in python
Date : March 29 2020, 07:55 AM
like below fixes the issue Here is an example to do it without matplotlib.collections.LineCollection. The idea is to first identify the cross-over point and then using a plot function via groupby. import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# simulate data
# =============================
np.random.seed(1234)
df = pd.DataFrame({'px_last': 100 + np.random.randn(1000).cumsum()}, index=pd.date_range('2010-01-01', periods=1000, freq='B'))
df['50dma'] = pd.rolling_mean(df['px_last'], window=50)
df['200dma'] = pd.rolling_mean(df['px_last'], window=200)
df['label'] = np.where(df['50dma'] > df['200dma'], 1, -1)
# plot
# =============================
df = df.dropna(axis=0, how='any')
fig, ax = plt.subplots()
def plot_func(group):
global ax
color = 'r' if (group['label'] < 0).all() else 'g'
lw = 2.0
ax.plot(group.index, group.px_last, c=color, linewidth=lw)
df.groupby((df['label'].shift() * df['label'] < 0).cumsum()).apply(plot_func)
# add ma lines
ax.plot(df.index, df['50dma'], 'k--', label='MA-50')
ax.plot(df.index, df['200dma'], 'b--', label='MA-200')
ax.legend(loc='best')
|
Plot Multicolored Time Series Plot based on Conditional in Python
Tag : python , By : Ryan Adriano
Date : March 29 2020, 07:55 AM
will help you Here's an example of what I think your trying to do. It's based on the MPL documentation mentioned in the comments and uses randomly generated data. Just map the colormap boundaries to the discrete values given by the number of classes. import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
from matplotlib.colors import ListedColormap, BoundaryNorm
import pandas as pd
num_classes = 4
ts = range(10)
df = pd.DataFrame(data={'TOTAL': np.random.rand(len(ts)), 'Label': np.random.randint(0, num_classes, len(ts))}, index=ts)
print(df)
cmap = ListedColormap(['r', 'g', 'b', 'y'])
norm = BoundaryNorm(range(num_classes+1), cmap.N)
points = np.array([df.index, df['TOTAL']]).T.reshape(-1, 1, 2)
segments = np.concatenate([points[:-1], points[1:]], axis=1)
lc = LineCollection(segments, cmap=cmap, norm=norm)
lc.set_array(df['Label'])
fig1 = plt.figure()
plt.gca().add_collection(lc)
plt.xlim(df.index.min(), df.index.max())
plt.ylim(-1.1, 1.1)
plt.show()
|
What is the best way of making a multicolored background without adding in an image?
Tag : html , By : damomurf
Date : March 29 2020, 07:55 AM
|