# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=762

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 763

---

## [How yo plot grid lines top of heatmap by using Plots.heatmap?](https://discourse.julialang.org/t/how-yo-plot-grid-lines-top-of-heatmap-by-using-plots-heatmap/37985)

<div class="topic-metadata">

**Author:** [@Peichao](https://discourse.julialang.org/u/Peichao)\
**Replies:** 0\
**Last updated:** [April 21, 2020, 6:39pm UTC](https://discourse.julialang.org/t/how-yo-plot-grid-lines-top-of-heatmap-by-using-plots-heatmap/37985 "2020-04-21T18:39:24Z")

</div>

I notice when I am using Plots.heatmap, the grid lines are covered by the heatmap. I am wondering how to show the grid lines on top of heatmap with specific line style, color, and thickness? Thanks in advance!

---

## [How to define a Sampler for an object?](https://discourse.julialang.org/t/how-to-define-a-sampler-for-an-object/37965)

<div class="topic-metadata">

**Author:** [@logankilpatrick](https://discourse.julialang.org/u/logankilpatrick)\
**Replies:** 5\
**Last updated:** [April 21, 2020, 5:04pm UTC](https://discourse.julialang.org/t/how-to-define-a-sampler-for-an-object/37965 "2020-04-21T17:04:32Z")

</div>

Hey all, I am getting an error when trying to use the Rand function for my custom type. The error is: ERROR: LoadError: ArgumentError: Sampler for this object is not defined I read the docs here and here but it is n…

---

## [!isnan.() doesn't work](https://discourse.julialang.org/t/isnan-doesnt-work/37934)

<div class="topic-metadata">

**Author:** [@Jing\_Zhang](https://discourse.julialang.org/u/Jing_Zhang)\
**Replies:** 9\
**Last updated:** [April 21, 2020, 4:44pm UTC](https://discourse.julialang.org/t/isnan-doesnt-work/37934 "2020-04-21T16:44:23Z")

</div>

Dear Julia user, Why does isnan.(\[0 0/0\]) return a 1×2 BitArray{2}: false true, but !isnan.(\[0 0/0\]) return an error message: no method matching !(::BitArray{2})? Thanks a lot!

---

## [Matrices with vectors in elements?](https://discourse.julialang.org/t/matrices-with-vectors-in-elements/37949)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 4\
**Last updated:** [April 21, 2020, 3:33pm UTC](https://discourse.julialang.org/t/matrices-with-vectors-in-elements/37949 "2020-04-21T15:33:46Z")

</div>

I’m a little puzzled about how to fill vectors into matrix elements… Consider the two attempts below: the first is unsuccessful, the second is successful. julia\> # Unsuccessful strategy julia\> a11 = \[1,2\]; julia\> a12 = …

---

## [Weave.jl: jmd -\> md -\> pdf](https://discourse.julialang.org/t/weave-jl-jmd-md-pdf/37970)

<div class="topic-metadata">

**Author:** [@dpo](https://discourse.julialang.org/u/dpo)\
**Replies:** 0\
**Last updated:** [April 21, 2020, 3:07pm UTC](https://discourse.julialang.org/t/weave-jl-jmd-md-pdf/37970 "2020-04-21T15:07:45Z")

</div>

I asked this question on Slack but no answer so far. I use Weave.jl to convert a jmd file to pandoc format. Julia code blocks end up being annotated with {.julia}. I then convert to PDF via \\LaTeX with the --listin…

---

## [How bad is type piracy actually?](https://discourse.julialang.org/t/how-bad-is-type-piracy-actually/37913)

<div class="topic-metadata">

**Author:** [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Replies:** 12\
**Last updated:** [April 21, 2020, 2:02pm UTC](https://discourse.julialang.org/t/how-bad-is-type-piracy-actually/37913 "2020-04-21T14:02:38Z")

</div>

In the world of C, typedef/struct definitions mostly reside in header files and can be included at will, so a type can be made available for interfacing between libraries. In the world of julia type defintions reside wi…

---

## [How to get dependencies of latest version from Deps.toml?](https://discourse.julialang.org/t/how-to-get-dependencies-of-latest-version-from-deps-toml/37942)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 2\
**Last updated:** [April 21, 2020, 5:43am UTC](https://discourse.julialang.org/t/how-to-get-dependencies-of-latest-version-from-deps-toml/37942 "2020-04-21T05:43:36Z")

</div>

Let’s say you have a Deps.toml file: Deps.toml How do you parse it to get the dependency packages that the latest version would have? // related to: JuliaPackages.jl#3 One hiccup is I have no clue what \["0.14-0"\] m…

---

## [Global variable cannot be read within if-else-loop](https://discourse.julialang.org/t/global-variable-cannot-be-read-within-if-else-loop/37932)

<div class="topic-metadata">

**Author:** [@kendrawu](https://discourse.julialang.org/u/kendrawu)\
**Replies:** 2\
**Last updated:** [April 21, 2020, 5:20am UTC](https://discourse.julialang.org/t/global-variable-cannot-be-read-within-if-else-loop/37932 "2020-04-21T05:20:59Z")

</div>

Here is a sample code I have created: function fn\_update\_a(a, b, c, d) a = fn(c,d) b = vcat(b,a) return a, b end for isim in 1:10 a = fn(c, d) if isim==1 b = deepcopy(a) else a=1 pri…

---

## [Because size() doesn't work](https://discourse.julialang.org/t/because-size-doesnt-work/37939)

<div class="topic-metadata">

**Author:** [@EmilioAlvizo](https://discourse.julialang.org/u/EmilioAlvizo)\
**Replies:** 6\
**Last updated:** [April 21, 2020, 2:07am UTC](https://discourse.julialang.org/t/because-size-doesnt-work/37939 "2020-04-21T02:07:22Z")

</div>

I want to size the array dimensions which in this case are 5 and 6, but I don’t know why it doesn’t A=zeros(5,6) size(A) and I get the following error MethodError: objects of type Tuple{Int64,Int64} are not callable

---

## [DifferentialEquations deal with oscillations](https://discourse.julialang.org/t/differentialequations-deal-with-oscillations/35650)

<div class="topic-metadata">

**Author:** [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Replies:** 10\
**Last updated:** [April 20, 2020, 10:19pm UTC](https://discourse.julialang.org/t/differentialequations-deal-with-oscillations/35650 "2020-04-20T22:19:46Z")

</div>

Hello, I don’t know if this is more a math question than computational one, but since in the end the implementation with Julia is what I seek, I am posting it here. I am using DifferentialEquations to model some data th…

---

## [Can one override "using" or "import" keywords?](https://discourse.julialang.org/t/can-one-override-using-or-import-keywords/37924)

<div class="topic-metadata">

**Author:** [@xzackli](https://discourse.julialang.org/u/xzackli)\
**Replies:** 2\
**Last updated:** [April 20, 2020, 9:07pm UTC](https://discourse.julialang.org/t/can-one-override-using-or-import-keywords/37924 "2020-04-20T21:07:29Z")

</div>

Is it possible to change the behavior of a particular import or using command? I know this sounds pretty terrible, and I’m only 10% serious about actually doing this. In particular, can one modify import SomePackage to t…

---

## [SSL with MYSQL.jl](https://discourse.julialang.org/t/ssl-with-mysql-jl/37928)

<div class="topic-metadata">

**Author:** [@victora](https://discourse.julialang.org/u/victora)\
**Replies:** 0\
**Last updated:** [April 20, 2020, 8:58pm UTC](https://discourse.julialang.org/t/ssl-with-mysql-jl/37928 "2020-04-20T20:58:31Z")

</div>

Hello everyone - I have been trying unsuccessfully to connect to a mysql db in a jupyter notebook with the following: ( using JuliaPro install ) # connecting to mysql using MySQL, DBInterface, Tables, DataFrames conn = …

---

## [How to groupby a column and take the mean while ignoring missing values](https://discourse.julialang.org/t/how-to-groupby-a-column-and-take-the-mean-while-ignoring-missing-values/37918)

<div class="topic-metadata">

**Author:** [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Replies:** 1\
**Last updated:** [April 20, 2020, 8:36pm UTC](https://discourse.julialang.org/t/how-to-groupby-a-column-and-take-the-mean-while-ignoring-missing-values/37918 "2020-04-20T20:36:06Z")

</div>

Hi how’s it going, I’m trying to do by(df, col1, numeric\_col=\>mean) however it’s not working. I tried skipmissing=true but turns out that skips any group that has even 1 missing value. If the values of numeric\_col for …

---

## [How to plot a simple stacked area chart](https://discourse.julialang.org/t/how-to-plot-a-simple-stacked-area-chart/21351)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 5\
**Last updated:** [April 20, 2020, 8:29pm UTC](https://discourse.julialang.org/t/how-to-plot-a-simple-stacked-area-chart/21351 "2020-04-20T20:29:21Z")

</div>

All I need to do is to plot a simple stacked chart (possibly also normalised). I would like to start from these simple data: a = \[1,1,1,1.5,2,3\] b = \[0.5,0.6,0.4,0.3,0.3,0.2\] c = \[2,1.8,2.2,3.3,2.5,1.8\] sNames = \["a","…

---

## [Connecting RShiny to a running instance of Julia](https://discourse.julialang.org/t/connecting-rshiny-to-a-running-instance-of-julia/37869)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 4\
**Last updated:** [April 20, 2020, 3:03pm UTC](https://discourse.julialang.org/t/connecting-rshiny-to-a-running-instance-of-julia/37869 "2020-04-20T15:03:35Z")

</div>

I have a simulation model in Julia that has the following workflow using SimModel addprocs(SlurmManager(512)) @everywhere using SimModel run\_simulation(params) # function uses pmap to launch work() over 500 processors…

---

## [How to use hook to clip a gradient?](https://discourse.julialang.org/t/how-to-use-hook-to-clip-a-gradient/37896)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 4\
**Last updated:** [April 20, 2020, 2:17pm UTC](https://discourse.julialang.org/t/how-to-use-hook-to-clip-a-gradient/37896 "2020-04-20T14:17:03Z")

</div>

I’m trying to train a neural network using gradient clipping. I’m trying to understand how the hook function works. Let’s define a model and a clip function using Zygote, LinearAlgebra clip(g) = g./norm(g) a = 2; b = 1…

---

## [Efficiently remove diagonal from Array](https://discourse.julialang.org/t/efficiently-remove-diagonal-from-array/37893)

<div class="topic-metadata">

**Author:** [@Sajmon](https://discourse.julialang.org/u/Sajmon)\
**Replies:** 9\
**Last updated:** [April 20, 2020, 1:56pm UTC](https://discourse.julialang.org/t/efficiently-remove-diagonal-from-array/37893 "2020-04-20T13:56:05Z")

</div>

I’m trying to remove the diagonal from a two-dimensional square Array. I have come up with the code below but it’s not very efficient (e.g., on a 1000 x 1000 matrix, it allocates 75MiB and takes about 65ms on my machine)…

---

## [Reading and writing to file simultaneously](https://discourse.julialang.org/t/reading-and-writing-to-file-simultaneously/37761)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 4\
**Last updated:** [April 20, 2020, 10:54am UTC](https://discourse.julialang.org/t/reading-and-writing-to-file-simultaneously/37761 "2020-04-20T10:54:37Z")

</div>

I’m streaming data from the web and writing to file in a random fashion every second or two, and opening and closing on each write. If I want to sometimes read everything in the file up to this point, is that a problem? …

---

## [Iterate over the integer gridpoints in a simplex](https://discourse.julialang.org/t/iterate-over-the-integer-gridpoints-in-a-simplex/37886)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 1\
**Last updated:** [April 20, 2020, 10:36am UTC](https://discourse.julialang.org/t/iterate-over-the-integer-gridpoints-in-a-simplex/37886 "2020-04-20T10:36:08Z")

</div>

I would like to iterate over all x::NTuple{N,Int} such that all(x .\>= 0) && sum(x) == K (ie integer gridpoints in a simplex). For small problems a brute force approach function simplex\_integer\_grid(::Val{N}, K) where N …

---

## [Comparing with nothing](https://discourse.julialang.org/t/comparing-with-nothing/37888)

<div class="topic-metadata">

**Author:** [@hmemy](https://discourse.julialang.org/u/hmemy)\
**Replies:** 9\
**Last updated:** [April 20, 2020, 10:20am UTC](https://discourse.julialang.org/t/comparing-with-nothing/37888 "2020-04-20T10:20:55Z")

</div>

How to compare with the value nothing? I came up with this small piece of lines but it is not working. A = \[1,2,3\] if indexin(USER\_INPUT,A) !== nothing do\_someething() end Thank you

---

## [Allocation of distributed arrays to workers](https://discourse.julialang.org/t/allocation-of-distributed-arrays-to-workers/37721)

<div class="topic-metadata">

**Author:** [@Diego](https://discourse.julialang.org/u/Diego)\
**Replies:** 5\
**Last updated:** [April 20, 2020, 9:34am UTC](https://discourse.julialang.org/t/allocation-of-distributed-arrays-to-workers/37721 "2020-04-20T09:34:52Z")

</div>

By default when creating a distributed array each worker is assigned consecutive fields. So for a 10 element array, worker 1 would control 1:5 and worker 2 6:10. ¿Is there a way of defining the DArrays in a way that wo…

---

## [Including raw HTML in Julia Markdown](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165)

<div class="topic-metadata">

**Author:** [@Rajesh\_Talluri](https://discourse.julialang.org/u/Rajesh_Talluri)\
**Replies:** 12\
**Last updated:** [April 20, 2020, 9:01am UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165 "2020-04-20T09:01:54Z")

</div>

Hi, I am trying to create a report in Julia markdown using the Weave.jl Package. However, I got stuck when using raw HTML or JavaScript in the document as it does not get rendered correctly. Using pandoc to convert the …

---

## [Alternative to SharedArrays for multi-node cluster?](https://discourse.julialang.org/t/alternative-to-sharedarrays-for-multi-node-cluster/37794)

<div class="topic-metadata">

**Author:** [@Nadou407](https://discourse.julialang.org/u/Nadou407)\
**Replies:** 9\
**Last updated:** [April 20, 2020, 8:02am UTC](https://discourse.julialang.org/t/alternative-to-sharedarrays-for-multi-node-cluster/37794 "2020-04-20T08:02:55Z")

</div>

Hello! I’m moving my codes from my own computer to a multi-node cluster and realized SharedArrays won’t work on multiple nodes without shared memory. The old code using SharedArrays looks like below: using Distributed…

---

## [Pkg, instantiate error](https://discourse.julialang.org/t/pkg-instantiate-error/37878)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 5\
**Last updated:** [April 20, 2020, 7:31am UTC](https://discourse.julialang.org/t/pkg-instantiate-error/37878 "2020-04-20T07:31:20Z")

</div>

I found the command instantiate encountered errors in Julia1.3, which works quite well before. I have developed a package, hotspot, I run the following commands. (v1.3) pkg\> activate . Activating environment at \`~/juli…

---

## [Does Markdown support comments?](https://discourse.julialang.org/t/does-markdown-support-comments/37607)

<div class="topic-metadata">

**Author:** [@KDr2](https://discourse.julialang.org/u/KDr2)\
**Replies:** 11\
**Last updated:** [April 20, 2020, 6:49am UTC](https://discourse.julialang.org/t/does-markdown-support-comments/37607 "2020-04-20T06:49:11Z")

</div>

I am writing docs for a package, using Emacs, and I want to put some file local variables in the markdown files, I tried: \[//\]: # -\*- mode: auto-fill -\*- \<!-- -\*- mode: auto-fill -\*- --\> But these lines are not recogni…

---

## [Priority of environments](https://discourse.julialang.org/t/priority-of-environments/37873)

<div class="topic-metadata">

**Author:** [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Replies:** 0\
**Last updated:** [April 20, 2020, 1:40am UTC](https://discourse.julialang.org/t/priority-of-environments/37873 "2020-04-20T01:40:05Z")

</div>

Summary: How can I install a package locally and on a server, where both locations are in DEPOT\_PATH &/or LOAD\_PATH, but local version takes priority? I have a setup with multiple machines, and for ease of management, …

---

## [Float -\> Rational numbers?](https://discourse.julialang.org/t/float-rational-numbers/37856)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 15\
**Last updated:** [April 19, 2020, 8:32pm UTC](https://discourse.julialang.org/t/float-rational-numbers/37856 "2020-04-19T20:32:09Z")

</div>

I’m curious about the possibility to convert Float64 numbers to Rational numbers for exact computations. I’m a little puzzled by the following: julia\> x = 2.64 2.64 julia\> y = Rational(x) 5944751508129055//225179981368…

---

## [Communicating with external C threads](https://discourse.julialang.org/t/communicating-with-external-c-threads/37696)

<div class="topic-metadata">

**Author:** [@OliverEvans96](https://discourse.julialang.org/u/OliverEvans96)\
**Replies:** 8\
**Last updated:** [April 19, 2020, 6:13pm UTC](https://discourse.julialang.org/t/communicating-with-external-c-threads/37696 "2020-04-19T18:13:32Z")

</div>

Hi all, According to this section of the docs as well as numerous discussions on discourse and the email list, it’s apparently not allowed to call julia functions from external C threads other than the one that spawned …

---

## [IJulia and magic command](https://discourse.julialang.org/t/ijulia-and-magic-command/37860)

<div class="topic-metadata">

**Author:** [@Oto\_Brzobohaty](https://discourse.julialang.org/u/Oto_Brzobohaty)\
**Replies:** 1\
**Last updated:** [April 19, 2020, 5:28pm UTC](https://discourse.julialang.org/t/ijulia-and-magic-command/37860 "2020-04-19T17:28:15Z")

</div>

I would like to use Jupyter interactive widgets framework, ipympl with IJulia and PyPlot. I installed ipympl using pip3 install ipympl and then I tested it in the Jupyter notebook with python kernel using this simple e…

---

## [Construction Overhead for MvNormal](https://discourse.julialang.org/t/construction-overhead-for-mvnormal/37732)

<div class="topic-metadata">

**Author:** [@bmit](https://discourse.julialang.org/u/bmit)\
**Replies:** 4\
**Last updated:** [April 19, 2020, 3:32pm UTC](https://discourse.julialang.org/t/construction-overhead-for-mvnormal/37732 "2020-04-19T15:32:19Z")

</div>

MvNormal distributions in the Distributions package have a large construction overhead because the underlaying PDMats package performs a full Cholesky decomposition of the covariance matrix. In theory, I think this can b…

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=761)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=763)
