logo
Tags down

shadow

How to I get scatter plot to have different colour for each value that I am plotting?


By : qingze ma
Date : July 29 2020, 03:00 PM
wish of those help I used read.xlsx to get a data from excel. What I want to do with the data is that I want to plot a scatterplot with latitude as my y-axis and longitude as my x-axis. I want to have a count label such that it shows the scale of my value and with the lower value colored blue and the highest value being red. How do I do this? Currently this is my data. , Try:
code :
getdata <- data.frame(
    latitude=c(22.23418, 1.15923, 37.60778, 27.65468, 33.61151), 
    longitude=c(80.71113, 115.82203, 96.09940, 127.00649, 166.54130),
    Value=c(0.696, 0.686, 0.459, 0.718, 0.837))

library(ggplot2)
ggplot(data=getdata, aes(x = longitude, y = latitude, color=Value))+
        geom_point()+
        scale_color_continuous( low = "blue", high = "red")


Share : facebook icon twitter icon

Plotting means as a line plot onto a scatter plot with ggplot


By : Fab
Date : March 29 2020, 07:55 AM
around this issue I have this simple data frame holding three replicates (value) for each factor (CT). I would like to plot it as geom_point and than the means of the point as geom_line. , You should set the group aes to 1:
code :
ggplot(df, aes(x=CT, y=value)) + geom_point() +
  stat_summary(aes(y = value,group=1), fun.y=mean, colour="red", geom="line",group=1)

matplotlib: plotting histogram plot just above scatter plot


By : James4589
Date : March 29 2020, 07:55 AM
I wish this help you I would like to make beautiful scatter plots with histograms above and right of the scatter plot, as it is possible in seaborn with jointplot: , Here's an example of how to do it, using gridspec.GridSpec:
code :
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
import numpy as np

x = np.random.rand(50)
y = np.random.rand(50)

fig = plt.figure()

gs = GridSpec(4,4)

ax_joint = fig.add_subplot(gs[1:4,0:3])
ax_marg_x = fig.add_subplot(gs[0,0:3])
ax_marg_y = fig.add_subplot(gs[1:4,3])

ax_joint.scatter(x,y)
ax_marg_x.hist(x)
ax_marg_y.hist(y,orientation="horizontal")

# Turn off tick labels on marginals
plt.setp(ax_marg_x.get_xticklabels(), visible=False)
plt.setp(ax_marg_y.get_yticklabels(), visible=False)

# Set labels on joint
ax_joint.set_xlabel('Joint x label')
ax_joint.set_ylabel('Joint y label')

# Set labels on marginals
ax_marg_y.set_xlabel('Marginal x label')
ax_marg_x.set_ylabel('Marginal y label')
plt.show()

Plot function of x, y as the colour density on a scatter plot?


By : jessamar rayos
Date : March 29 2020, 07:55 AM
With these it helps Say I have a list of heights that a measurement were taken from: , Here's what you need:
code :
plt.scatter(angle[x], height_temp, c=slope[x], s=slope[y], cmap='rainbow')

Plotting circles with no fill, colour & size depending on variables using scatter


By : Denys Samoilenko
Date : March 29 2020, 07:55 AM
Hope that helps I believe doing both approaches may achieve what you are trying to do. First draw the unfilled circles, then do a scatter plot with the same points. For the scatter plots, make the size 0 but use it to set the colorbar.
Consider the following example:
code :
import numpy as np
from matplotlib import pyplot as plt
import matplotlib.cm as cm

%matplotlib inline

# generate some random data
npoints = 5
x = np.random.randn(npoints)
y = np.random.randn(npoints)

# make the size proportional to the distance from the origin
s = [0.1*np.linalg.norm([a, b]) for a, b in zip(x, y)]
s = [a / max(s) for a in s]  # scale

# set color based on size
c = s
colors = [cm.jet(color) for color in c]  # gets the RGBA values from a float

# create a new figure
plt.figure()
ax = plt.gca()
for a, b, color, size in zip(x, y, colors, s):
    # plot circles using the RGBA colors
    circle = plt.Circle((a, b), size, color=color, fill=False)
    ax.add_artist(circle)

# you may need to adjust the lims based on your data
minxy = 1.5*min(min(x), min(y))
maxxy = 1.5*max(max(x), max(y))
plt.xlim([minxy, maxxy])
plt.ylim([minxy, maxxy])
ax.set_aspect(1.0)  # make aspect ratio square

# plot the scatter plot
plt.scatter(x,y,s=0, c=c, cmap='jet', facecolors='none')
plt.grid()
plt.colorbar()  # this works because of the scatter
plt.show()

plotting a density plot and a scatter plot on the same figure


By : user2741583
Date : March 29 2020, 07:55 AM
I hope this helps you . I will like replicate the combined plot of density plot and scatter plot as in Figure 3 of of this paper:
code :
library(ggplot2)
ggplot(iris, aes(Sepal.Width)) + 
  geom_histogram(binwidth = 0.3, fill = "gray70", color = "white") +
  geom_jitter(aes(y = -5), height = 3, alpha = 0.2) +
  theme_classic()
Related Posts Related Posts :
  • Merging data frames with partial Matching using R
  • Trouble extracting a string from a character vector
  • Make a column based on the difference of 2 objects in a seperate column in R
  • replace with a new string if text contains a specific character in r
  • How to terminate R from terminal?
  • Remove values ending with specific character in R
  • Convert decimal to date format in r
  • Separate a row into many using separated by
  • par(mfrow = c(x, y)) not working in Rmd inline output
  • How to create a new column in R which matches multiple values from two different data frames
  • Remove a pattern in a string and mutate these values to a new column
  • Error when running mixed effects model -- Error: number of levels of each grouping factor must be < number of observa
  • R - call xts via character
  • Is there an R function to identify and modify column names across dataframes in the same List?
  • how to do the for-loop for integrate() in R
  • How to maintain the order of the variables according to the third factor variable in ggplot?
  • For-loop to summarize and joining by dplyr
  • knitr to PDF not wrapping comments
  • Calculating the log-likelihood of a set of observations sampled from a mixture of two normal distributions using R
  • Why is this function in R placing a back slash in front of a decimal point?
  • Automatically install most useful packages
  • Issue in ggplot with continuous x axis as year
  • How can I get R to follow symbolic links in Windows 10?
  • Is there a function in R that will sum values based on Date of Year?
  • How to check the equality of two covariance matrices?
  • Using multiple logical criteria for subsetting in r
  • Removing rows from a dataframe based on another dataframe
  • Write RFC4180 compatible flat files with less agressive quoting
  • How to use mutate() with a Date_Time month/Day/Year 00:00 in R
  • writing R function with ggplot
  • Find the birthdаte using age and date of die
  • How to rename all column names in tibble by passing a character vector?
  • Trouble converting list to dataframe
  • Filtering column based on matching conditions in another column
  • How to pass a column name as an argument of a function which uses dplyr, without passing it as a string?
  • Changing column values for each unique value based on a condition
  • Unable to re-read file despite seek()
  • Create new column of vectors from two columns in R data frame
  • Trying to add legend using geom_abline
  • Why doesn't this R code produce the same result? (Convolution vs FFT)
  • open source shiny server on an instance on gcp can't connect to cloud sql
  • Mixed Date formats in R data frame
  • How to write a function in r which plots data for each unique value?
  • How to create a count up data frame
  • Force imap to use index on named vector
  • How to extract from string with regex, a word and or condition
  • Filter all rows with word next to a specified word in R
  • Install package dependency that has no binary version
  • Function to use "-" as text
  • how to extract number (X>=0)
  • R - type detection / conversion
  • How to rank a vector using a second vector as a tie breaker?
  • R: Find the character position of where 2 strings differentiate
  • My plot has three layers and won't let me change the legend?
  • How to add all the predictors at once and produce a logistic model against the response
  • How to replace NA with set of values
  • How to invert a full matrix?
  • Testing and density plot across multiple columns
  • Count numbers that are lower by constant from current number
  • expression() command in R with semicolons
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org