plot

Plotting the predictions of a mixed model as a line in R

三世轮回 提交于 2021-02-07 10:51:39
问题 I'm trying to plot the predictions ( predict() ) of my mixed model below such that I can obtain my conceptually desired plot as a line below. I have tried to plot my model's predictions, but I don't achieve my desired plot. Is there a better way to define predict() so I can achieve my desired plot? library(lme4) dat3 <- read.csv('https://raw.githubusercontent.com/rnorouzian/e/master/dat3.csv') m4 <- lmer(math~pc1+pc2+discon+(pc1+pc2+discon|id), data=dat3) newdata <- with(dat3, expand.grid(pc1

How to color states in US map in R

隐身守侯 提交于 2021-02-07 10:31:27
问题 I want to draw a US map with some states have blue color and others have white color Now, I have the list of names of state: c=c("ILLINOIS", "KANSAS","LOUISIANA","MAINE","MICHIGAN","MINNESOTA","MISSISSIPPI" ) However, when I use: map(database = "state",regions = c,col = "blue",fill=T) It only shows: This is not I want, I want to see other states with white color, what should I do? 回答1: @rawr solution in comments worked. to create a full map with fill colors: map(database = "state") map

How to color states in US map in R

拈花ヽ惹草 提交于 2021-02-07 10:31:24
问题 I want to draw a US map with some states have blue color and others have white color Now, I have the list of names of state: c=c("ILLINOIS", "KANSAS","LOUISIANA","MAINE","MICHIGAN","MINNESOTA","MISSISSIPPI" ) However, when I use: map(database = "state",regions = c,col = "blue",fill=T) It only shows: This is not I want, I want to see other states with white color, what should I do? 回答1: @rawr solution in comments worked. to create a full map with fill colors: map(database = "state") map

How to color states in US map in R

坚强是说给别人听的谎言 提交于 2021-02-07 10:31:11
问题 I want to draw a US map with some states have blue color and others have white color Now, I have the list of names of state: c=c("ILLINOIS", "KANSAS","LOUISIANA","MAINE","MICHIGAN","MINNESOTA","MISSISSIPPI" ) However, when I use: map(database = "state",regions = c,col = "blue",fill=T) It only shows: This is not I want, I want to see other states with white color, what should I do? 回答1: @rawr solution in comments worked. to create a full map with fill colors: map(database = "state") map

Matlab dynamic legend / legend “hold on” like behavior

安稳与你 提交于 2021-02-07 09:41:20
问题 Just want to add more data do a legend without erasing it. Like a legend "hold on" Sample : plotData = array of plot data, like plotData(i) = plot(... N = size of plotData. Code : for i = 1:N str = sprintf('My plot y %d', i); %legendData(:,i) = [plotData; str]; %#ok<SAGROW> %[~,~,~,current_entries] = legend; %legend([current_entries [plotData; str]]); no sucess here % This command will erase the previous one. legend(plotData,str); end legend([plotX1,plotX2],'x 1','x 2'); I think I can store

Matlab dynamic legend / legend “hold on” like behavior

巧了我就是萌 提交于 2021-02-07 09:40:28
问题 Just want to add more data do a legend without erasing it. Like a legend "hold on" Sample : plotData = array of plot data, like plotData(i) = plot(... N = size of plotData. Code : for i = 1:N str = sprintf('My plot y %d', i); %legendData(:,i) = [plotData; str]; %#ok<SAGROW> %[~,~,~,current_entries] = legend; %legend([current_entries [plotData; str]]); no sucess here % This command will erase the previous one. legend(plotData,str); end legend([plotX1,plotX2],'x 1','x 2'); I think I can store

Matlab dynamic legend / legend “hold on” like behavior

强颜欢笑 提交于 2021-02-07 09:40:28
问题 Just want to add more data do a legend without erasing it. Like a legend "hold on" Sample : plotData = array of plot data, like plotData(i) = plot(... N = size of plotData. Code : for i = 1:N str = sprintf('My plot y %d', i); %legendData(:,i) = [plotData; str]; %#ok<SAGROW> %[~,~,~,current_entries] = legend; %legend([current_entries [plotData; str]]); no sucess here % This command will erase the previous one. legend(plotData,str); end legend([plotX1,plotX2],'x 1','x 2'); I think I can store

Timeserie datetick problems when using pandas.DataFrame.plot method

折月煮酒 提交于 2021-02-07 09:31:34
问题 I just discovered something really strange when using plot method of pandas.DataFrame . I am using pandas 0.19.1 . Here is my MWE: import numpy as np import matplotlib.pyplot as plt import matplotlib.dates as mdates import pandas as pd t = pd.date_range('1990-01-01', '1990-01-08', freq='1H') x = pd.DataFrame(np.random.rand(len(t)), index=t) fig, axe = plt.subplots() x.plot(ax=axe) plt.show(axe) xt = axe.get_xticks() When I try to format my xticklabels I get strange beahviours, then I

Plotting one sigma error bars on a curve fit line in scipy

不打扰是莪最后的温柔 提交于 2021-02-07 09:09:58
问题 I plotted a linear least square fit curve using scipy.optimize.curve_fit() . My data has some error associated to it and I added those while plotting the fit curve. Next, I want to plot two dashed lines representing one sigma error bar on the curve fit and shade region between those two lines. This is what I have tried so far: import sys import os import numpy import matplotlib.pyplot as plt from pylab import * import scipy.optimize as optimization from scipy.optimize import curve_fit xdata =

Plotly: How to save plotly express plot into a html or static image file?

£可爱£侵袭症+ 提交于 2021-02-07 09:02:33
问题 I love plotly and recently plotly.express. However, I feel saving the figure is pretty tricky. How to save plotly.express or plotly plot into a individual html or static image file? Anyone can help? Thanks 回答1: Updated answer: With newer versions of plotly, static Image pxport in Python is a breeze. Just make sure to install kaleido using: pip install -U kaleido or, for Anaconda: conda install -c conda-forge python-kaleido And then run fig.write_image("<filename>") and `.pdf` are all